Search code examples
cygwinldlinker-flags

What is the difference betwen --export-dynamic and --export-all-symbols?


After compiling on Cygwin with gcc or clang, ld complains about

/usr/bin/ld: warning: --export-dynamic is not supported for PE+ targets, did you mean --export-all-symbols?

Changing the linkerflag as suggested fixes this behavior, but I am not sure if this is correct. Therefore the question is simple:

What is the difference betwen --export-dynamic and --export-all-symbols?


Solution

  • --export-dynamic is for ELF targets:

    Note that this option is specific to ELF targeted ports. PE targets support a similar function to export all symbols from a DLL or EXE; see the description of ‘--export-all-symbols’ below.

    --export-all-symbols is for PE targets:

    This option is specific to the i386 PE targeted port of the linker

    It would probably have been possible to subsume both under --export-dynamic (because that was there first), but the implementation is completely different, and this leaked out to the ld command line interface.