Reputation: 3
I am compiling my code to create a shared library and finally linking them to the correct libraries(shared libraries). However when i view my shared library with "nm -u" it shows unresolved symbols, mainly from (libm.so and libstdc++.so). I have compiled it with the flags -Wl,--no-undefined -Wl,--no-undefined-version but during linking it doesnot report anything.
Are these symbols reported by nm for libm and libstdc++ intended? Please note that i am cross compiling for QNX OS.
Thanks in advance and kind Regards,
Upvotes: 0
Views: 1327
Reputation: 213606
Are these symbols reported by nm for libm and libstdc++ intended?
Yes: when you link against shared libraries, the symbols stay unresolved. They get bound to the definition in the shared library at runtime. That's what it means to link dynamically against other libraries.
Update:
i find other unresolved symbols too say for libsocket.so. It looks like this:
U connect@@libsocket.so.2
But the symbol for math libraries is like this:
U pow
Why is this difference even though all these are shared libraries.
This is because connect
in libsocket
is a versioned symbol, but pow
in libm
is not. You can read about versioned symbols here.
there is another shared library, to which when i link it shows this symbol:
W _ZN15HWPos15getCCount
Why is there this difference?
This is a weakly-defined symbol, not an unresolved one. You can read about weak ELF symbols here.
Upvotes: 3