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

Yogesh Marwaha yogeshm.007 at gmail.com
Sat Jul 12 10:43:27 EDT 2008


Here is a part from outpur of make VERBOSE=1

---------------------------
Linking CXX executable Gravity
cd /home/yogesh/gravity/New/app && /usr/bin/cmake -E cmake_link_script
CMakeFiles/Gravity.dir/link.txt --verbose=1
/usr/bin/c++    -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef
-Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith
-Wformat-security -fno-exceptions -fno-check-new -fno-common
-Woverloaded-virtual -fno-threadsafe-statics -fvisibility=hidden
-fvisibility-inlines-hidden -g -O2 -fno-reorder-blocks
-fno-schedule-insns -fno-inline  -fPIC -Wl,--enable-new-dtags
CMakeFiles/Gravity.dir/main.o  -o Gravity -rdynamic
-L/home/yogesh/gravity/New/library -L/home/yogesh/gravity/New/lib
../lib/libGravityCore.so -ltag -lphonon -lsolid -lkdecore -lkdeui
-lkdeui -lQtSvg -lSM -lICE -lX11 -lXext -lXft -lXau -lXdmcp -lXpm
-lstreamanalyzer -lstreams -lsolid -lQtGui -lkdecore -lQtCore
-lpthread -lQtNetwork -lQtDBus -lQtXml-lz -lbz2 -lresolv -lXtst
-lXcursor -lXfixes -lfam -lXrender -lkio -lsqlite3
-Wl,-rpath,/usr/local/lib
CMakeFiles/Gravity.dir/main.o: In function `main':
--------------------------

libGravityCore is being included, so this seems not the problem.

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).

As I said earlier, if the GravityCore is generated as a standard
library instead of shared everything is fine.

Regards,
--
Yogesh M

2008/7/12 Philip Lowman <philip at yhbt.com>:
>
> On Sat, Jul 12, 2008 at 7:21 AM, Yogesh Marwaha <yogeshm.007 at gmail.com> wrote:
>>
>> Hello, can someone figure out what I'm doing wrong.
>> Here is the output I get when I attempt to compile: -
>> =================================
>> yogesh at linux-sm3q:~/gravity/New> make
>> Scanning dependencies of target GravityCore
>> [ 91%] Built target GravityCore
>> Scanning dependencies of target Gravity
>> Linking CXX executable Gravity
>> CMakeFiles/Gravity.dir/main.o: In function `main':
>> /home/yogesh/gravity/app/main.cpp:10: undefined reference to `GApplication::GApplication()'
>> /home/yogesh/gravity/app/main.cpp:12: undefined reference to `Gravity::self()'
>> /home/yogesh/gravity/app/main.cpp:12: undefined reference to `Gravity::gUIInterfaceManager() const'
>> /home/yogesh/gravity/app/main.cpp:13: undefined reference to `GApplication::~GApplication()'
>> collect2: ld returned 1 exit status
>> make[2]: *** [app/Gravity] Error 1
>> make[1]: *** [app/CMakeFiles/Gravity.dir/all] Error 2
>> make: *** [all] Error 2
>> =================================
>
> I would do a "make VERBOSE=1" and verify that CMake is linking your executable against what you think it should be linking against.
>
> If that was not the problem, I'd have a second look at your library implementations and double check that you're compiling and linking what you think you're compiling and linking.  You can use "nm" or some other tool to inspect the generated shared libraries and ensure that the proper symbols are defined (or not defined).
>
> --
> Philip Lowman


More information about the CMake mailing list