2

There are a handful of related SO questions/answers but none of them seem to answer what I'm looking for. here, and here

I have some source that if I compile on Windows as a DLL I can analyze the DLL with Dependency Walker and see very clearly all the functions that I exported with extern "C". However, if I cross-compile the same source for Linux and use the methods referenced above I cannot find any of the functions that I exported in the ocean of information dumped out. Searching the output for strings with the names of the exported functions confirms that they are not listed.

Some of the methods I've tried include,

nm -C --defined-only -g libTest.so > out.txt
nm -D libTest.so > out.txt
nm -D --defined-only libTest.so > out.txt
nm -D --defined-only --demangled libTest.so > out.txt
objdump -s libTest.so > out.txt
objdump -t libTest.so > out.txt
objdump -T libTest.so > out.txt
etc...

None of these methods list a single function that I've exported. Is it not possible to reproduce the clean list of exported functions that a Windows DLL exports in a Linux shared library when built from the same source? Even a massive dump list that included the exported functions could work but I can't even get that.

Clearly I'm missing something here... thanks in advance.

  • 2
    `extern "C"` does not "export" anything. That's your problem. You haven't exported anything. Whoever told you that `extern "C"` exports a symbol from a shared library was completely wrong. That's not how you export anything. – Sam Varshavchik Dec 15 '17 at 00:27
  • Extending on above: `extern C` inhibits C++'s name mangling so your function names make sense to a world expecting C-like function names. Details here: https://stackoverflow.com/questions/1041866/in-c-source-what-is-the-effect-of-extern-c – user4581301 Dec 15 '17 at 00:46
  • Thanks for helping a noob out. That was my problem. Once I properly exported the functions using, __attribute__((visibility("default"))) my functions showed up in the report generated by "nm -D -C -g --defined-only libTest.so". Thanks all. – Southern.Cross Dec 15 '17 at 17:56
  • For the other noobs needing help with this topic, I found the following page very helpful: [https://gcc.gnu.org/wiki/Visibility](https://gcc.gnu.org/wiki/Visibility) – Southern.Cross Dec 15 '17 at 18:06

0 Answers0