[CMake] Problem linking to shared library (inside project) after upgrade to cmake 2.6

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Jul 12 16:04:13 EDT 2008


On 2008-07-12 14:33-0400 Philip Lowman wrote:

> On Sat, Jul 12, 2008 at 10:43 AM, Yogesh Marwaha <yogeshm.007 at gmail.com>
> wrote:
>
>> [...]I'm unable (atm) to grasp output of 'nm libGravityCore.so'; so am
>> attching its output for you to see (in a separate mail, awaiting
>> moderator's approval).
>>
>
> No need to post the contents of the entire thing, just grep for the symbols
> you care about:
>
> nm --demangle libGravityCore.so | grep "Gravity::self"
> nm --demangle libGravityCore.so | grep "GApplication::GApplication"
>
> If you see a big "U" on the second column (undefined) you're referencing the
> method but not defining it.  This is usually due to having the method
> defined in a header file but no implementation provided.
>
> If you don't see any matching symbol for the method, the method is not
> defined in libGravityCore.so and you will need to link your executable
> against additional libraries to resolve the symbol.

Yogesh, you may find "ldd -r libGravityCore.so" much easier to use than nm
since that -r option gives only the symbols that are not defined by the
combination of libraries that libGravityCore.so links to, rather than
dealing with undefined symbols one library at a time.  Also, if ldd (without
the -r option) tells you a library is not found, then you will have to use
LD_LIBRARY_PATH to help find it (and possibly the rpath linker option the
next time you build libGravityCore.so).

In fact, there was something about rpath and CMake-2.6.0 that came up
recently on list so I bet your problem is rpath is not set up properly for
you in the build tree.  But first use ldd to diagnose which libraries are
not found for your cmake-2.6.0 version, and then use make VERBOSE=1 for both
the cmake-2.4 version that works and the cmake-2.6 version that doesn't and
compare especially what rpath is being used for each when the library is
being built.  Note, rpath in the build tree works fine for 2.6.0, but
normally only if you set up your library linking in the recommended way with
find_library results.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list