Qt app can't resolve symbols from a .so which was built by qt creator

I have a .so which was built by qt creator (the source code in .c extension). It can be load by QLibrary but the symbols defined in the .so can't be resolved by QLibrary.

This is due to the C++ name mangling. Trying to use

nm -C my.so

will see it has name mangling. We need to add extern "C" to disable name mangling in order to let QLibrary resolve it.

We can disable name mangling by adding extern "C" into the function declaration.

extern "C" void foo();
void foo() {;}


留言

熱門文章