how to trace the origin of linked objects ?

Shony used Ask the Experts™
During the g++ link (cygwin), some unreferenced symbols occur. There is a "-M" option
for ld, for executable symbols being listed. I assume the undefined symbols
errors occur because of a mix of inconsistent libraries.
Is it possible to get a symbol listing during linkage, with information about the
originating library ?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


To make this more explicit:

Depending on the number of objects in a library, the program is eventually linked,
or there are unresolved references.

Some objects and libraries are given, on the linker commandline:
... (outputfile) -lm -L/usr/lib -lstdc++  iniD.o .... (object files) ... -L. -liniObjects

iniD.o(.text+0x1282d):iniD.cpp: undefined reference to `__assert'
./libiniObjects.a(icode.o)(.text+0x3d5):icode.cpp: undefined reference to `__assert'

It even cannot find a libstdc++ object:
./libiniObjects.a(entr.o)(.text+0x8a4):entr.cpp: undefined reference to `std::istream::seekg(std::fpos<_mbsta_t>)'

Is that because of missing libraries, or the wrong sequence of the files on the command line ?

Top Expert 2005
assert() is a macro defined in assert.h.

If you didn't #include <assert.h> before using it in your code,
the compiler assumes that assert is a function returning int.


When inserting <assert.h>, there were much more indefined references.
The following try was successful:
I extracted the module containing the __assert entry from one of the
libraries linked, a put it directly to the objects.
I assign the points now, because your comment was a hint for the solution.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial