trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: March 2012

CMake - how to add library to build?

From: "David C. Rankin" <drankinatty@...>
Date: Thu, 08 Mar 2012 18:09:57 -0600
All,

  How do I add a library to a build in TDE? For some reason, the tdegraphics
cmake setup does not include libXext. I have patched Makefile.am with -lXext and
it is not seen by cmake or used for the build?? (Eg. I patched ksnapshot
Makefile.am as follows):

ksnapshot_LDADD = $(LIB_TDEPRINT) -lXext

  However, the ksnapshot link still fails:

/usr/bin/ld: CMakeFiles/ksnapshot.dir/windowgrabber.cpp.o: undefined reference
to symbol 'XShapeQueryExtension'
/usr/bin/ld: note: 'XShapeQueryExtension' is defined in DSO
/usr/lib/libXext.so.6 so try adding it to the linker command line
/usr/lib/libXext.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

  I have looked at ConfigureChecks.cmake and all it includes is:

check_include_file( X11/extensions/shape.h HAVE_X11_EXTENSIONS_SHAPE_H )

  Can I tell cmake to include the library here? Or should the library inclusion
go elsewhere? If so where?

  Is there a link to the cmake functions available in a TDE build? That would be
very helpful to help packages not familiar with cmake held debug, etc..

  I have found tde_add_library, but I don't know if that can be used to add an
existing system library or if that is just to tell cmake to build and link the
library?? Also, there are several forms:

tde_add_library( kfaximage STATIC_PIC AUTOMOC
tde_add_library( kfaximage SHARED AUTOMOC
tde_add_library( ksvg SHARED

  If I can add libXext with tde_add_library would it be SHARED, STATIC_PIC and
with or without AUTOMOC?

  I'm also not convinced that the problem isn't with cmake not concatenating or
forming the link string properly after the problem encountered with libkscan.
Below in the full error, there are man files just listed without any -l or -L
preceding them. Is this correct? The full error I get with the
tdegraphics/ksnapshot build is:

[ 66%] Building CXX object ksnapshot/CMakeFiles/ksnapshot.dir/ksnapshotwidget.cpp.o
cd /build/src/build/ksnapshot && /usr/bin/c++   -DHAVE_CONFIG_H
-DKSNAPVERSION=\"0.7\" -march=i686 -mtune=generic -O2 -pipe -fstack-protector
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2   -DQT_NO_ASCII_CAST
-DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION
-DQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h -I/build/src/build/ksnapshot
-I/build/src/tdegraphics/ksnapshot -I/build/src/build -I/opt/trinity/include
-I/opt/tqt3/include -I/opt/trinity/include/tqt    -o
CMakeFiles/ksnapshot.dir/ksnapshotwidget.cpp.o -c
/build/src/build/ksnapshot/ksnapshotwidget.cpp
Linking CXX executable ksnapshot
cd /build/src/build/ksnapshot && /usr/bin/cmake -E cmake_link_script
CMakeFiles/ksnapshot.dir/link.txt --verbose=1
/usr/bin/c++   -march=i686 -mtune=generic -O2 -pipe -fstack-protector
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2   -DQT_NO_ASCII_CAST
-DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION
-DQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h
-Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu
CMakeFiles/ksnapshot.dir/ksnapshotiface_skel.cpp.o
CMakeFiles/ksnapshot.dir/main.cpp.o CMakeFiles/ksnapshot.dir/ksnapshot.cpp.o
CMakeFiles/ksnapshot.dir/regiongrabber.cpp.o
CMakeFiles/ksnapshot.dir/windowgrabber.cpp.o
CMakeFiles/ksnapshot.dir/ksnapshotwidget.cpp.o  -o ksnapshot -rdynamic
-L/opt/trinity/lib -L/opt/tqt3/lib /opt/trinity/lib/libtdeprint.so.4.2.0
/opt/trinity/lib/libkio.so.4.2.0 /opt/trinity/lib/libtdeui.so.4.2.0 -lfreetype
-lfontconfig /opt/trinity/lib/libtdesu.so.4.2.0 -lutil
/opt/trinity/lib/libkwalletclient.so.1.0.1 /opt/trinity/lib/libtdecore.so.4.2.0
/opt/trinity/lib/libDCOP.so.4.2.0 /opt/trinity/lib/libtdefx.so.4.2.0 -ltqt
-ltqt-mt -lXrender -lX11 -lz -lidn -lXcomposite -lICE -lSM
-Wl,-rpath,/opt/trinity/lib:/opt/tqt3/lib:
/usr/bin/ld: CMakeFiles/ksnapshot.dir/windowgrabber.cpp.o: undefined reference
to symbol 'XShapeQueryExtension'
/usr/bin/ld: note: 'XShapeQueryExtension' is defined in DSO
/usr/lib/libXext.so.6 so try adding it to the linker command line
/usr/lib/libXext.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [ksnapshot/ksnapshot] Error 1
make[2]: Leaving directory `/build/src/build'
make[1]: *** [ksnapshot/CMakeFiles/ksnapshot.dir/all] Error 2
make[1]: Leaving directory `/build/src/build'
make: *** [all] Error 2

  Thanks for any help you can offer.

-- 
David C. Rankin, J.D.,P.E.