I am building a binary which uses multiple components which are compiled as .so files. I am getting a flurry of linker errors which point to which .so file caused them, but can I get information about which files are calling undefined functions or if possible source code locations where undefined functions are being called? I am finding it too tedious to hunt down the function esp since lot of overloading and templates are being used (which means same name in many places). In windows, it shows which .o file caused the undefined symbol, but am stuck at the level of libraries in linux. I use g++ in linux. Any pointer would be useful.
Share
You are asking “which object file inside a shared library is causing the error”.
The problem is that by the time that shared library has been linked, all object files have been “fused together”, and no longer exist inside the shared library as separate entities, so your question is somewhat meaningless.
That said, if you do a debug build (with
-gflag), the linker will tell you which source file and line is causing the problem, which you then may be able to translate into the object file.If you can’t (e.g. because the problem symbol is referenced in a header file), you can ask the linker for help: rebuild the library again, passing the linker
-yflag:will tell you which object(s) reference
my_unresolved_symbol.Note: linker operates “below” C++, so you must pass the mangled name, e.g.
_Znwto it.