[Cmake] static libs and undefined references
Iker Arizmendi
iker at research.att.com
Thu, 08 Apr 2004 23:47:43 -0400
Damn link order :) I had placed my libraries in the
wrong order with respect to each other (my first
library, A, needed symbols from B but B appeared
first on the link line).
Regards,
Iker
Iker Arizmendi wrote:
> Hello all.
>
> I'm creating several static libraries as part of
> cmake project that are giving me a lot of grief.
>
> In short, we have a CMake project that creates several
> static libraries in two directories and an executable
> that uses them in a third. The libraries build just
> fine, and the executable builds fine, but fails during
> linking with "undefined reference" errors. I've checked
> the libraries in question to make sure they export
> those symbols with nm and they do. I've also checked
> the link line CMake creates and it includes the
> libraries that it should. In the past I've had
> errors like these and its always been something
> silly (forgetting to define a function or virtual dtor,
> missing a library on the link line, wrong link order,
> etc) but now I'm at a loss...
>
> Has anyone encountered this before?
>
> Regards,
> Iker
>
> Relevant info:
>
> cmake v. 1.8.2
> g++ v. 3.2.2
>
>
> Maybe relevant:
>
> - When dumping the symbols in the static library I notice
> that nm lists some of the symbols as both T and U (in
> the text section AND undefined). Should this be so?
>
> - CMake puts the executable's object file first in the link
> line followed by all the library locations (-L) and then the
> libraries to use (-l). When I move the executable's .o file
> to _after_ the libraries the number of undefined references
> is reduced (but unfortunately not eliminated). The symbols
> still listed as undefined are still symbols that appear in
> the symbol listing for the libraries in use - for some
> reason the linker doesn't see them.
>
>
>