Executable exporting symbols BUT not getting exported as they are unreferenced by the executable itself

I have a particular use case where executable needs to export certain symbols, which are imported and used by the dynamically loaded DLLs the executable loads on runtime.

The executable links with some static libraries, which actually have symbols that are exported while the DLLs use these static libraries headers to import those symbols.

If these symbols are not used or un-referenced in the executable, then the linker removes them and hence they do not get exported and hence not available for DLLs at load time.

This i solved on GCC / clang using –whole-archive and -force_load option respectively.

What about MSVC on windows? I use __declspec(dllexport) and __declspec(dllimport) for exporting and importing symbols on windows.

Source: gcc

Leave a Reply