Web lists-archives.com

Re: [Mingw-users] Symbols exported/not exported

> From: Elio Blanca <eblanca76@xxxxxxxxxxxxxxxxxxxxx>
> Date: Fri, 3 Feb 2017 23:26:23 +0100
> I found some useful code on the page:
> http://stackoverflow.com/questions/437432/is-there-a-way-to-find-all-the-functions-exposed-by-a-dll
> (the dll symbol enumerator)
> and with some trick, it compiled under windows too.

What's wrong with just using the 'pexports' utility from here:


which is part of MinGW?

> It doesn't list the function I was after, vfs_zip_load, although 'nm' can see it. Maybe the two 
> programs work in different ways.
> Those listed are functions exported by an included library, libzip.a
> Although it seemed odd, I thought the dll had a limited amount of entry, so I wanted to remove those 
> unneeded ones and not expose them in order to have more room for the entries I really wanted.
> Now, since those are not requested to be available into my plugin, I re-built libzip.a statically 
> and I removed any "__declspec(dllimport)" I could find in the function declarations. Rebuilt 
> libzip.a and re-built my plugin which needs libzip.a
> Second run of the dll function/entry lister:
> Now the exposed functions are far more than before! They still include functions from libzip.a (so 
> my attempt to not expose some functions failed) and more functions from libz.a too.

This is expected, AFAIK: if the compiler/linker see no functions being
explicitly exported, they will export _all_ of them.  If that's what
you want, you've found your solution.  An alternative is to mark the
function(s) you want to be exported with '__attribute__ ((dllexport))'
(or the equivalent MS-specific '__declspec(dllexport)').  yet another
alternative is to use -Wl,--export-all-symbols switch to the link
command that produces the DLL, which will do the same as removing any
attributes from all the symbols.

> But I also see the entry point I wanted, 'vfs_zip_load' and I'm now happy this way because the main 
> application can load the plugin.
> Honestly, I cannot say why some symbols get exposed and some other don't, and I'm not sure how this 
> whole thing worked

See above: it depends on which of them are marked with the export

Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe