[CMake] more linking problems

Alexander Neundorf a.neundorf-work at gmx.net
Wed Apr 20 02:14:08 EDT 2005


Hi, 
 
on my quest to compile KDE with cmake now I'm in the process of linking 
it all together. 
 
I have the following cmake code: 
 
ADD_LIBRARY(kdevelop SHARED ${kdevelop_LIB_SRCS}) 
  
TARGET_LINK_LIBRARIES(kdevelop ${QT_LIBRARIES}  
kdecore kdeui kscript ktexteditor 
${CMAKE_BINARY_DIR}/lib/interfaces/libkdevinterfaces.a 
${CMAKE_BINARY_DIR}/lib/interfaces/external/libkinterfacedesigner.so 
${CMAKE_BINARY_DIR}/lib/interfaces/extensions/libkdevextensions.a 
${CMAKE_BINARY_DIR}/lib/util/libkdevutil.a 
${CMAKE_BINARY_DIR}/lib/widgets/propeditor/libkdevpropertyeditor.so ) 
 
and this is what I get: 
 
c++ -fPIC -Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -shared  
-Wl,-soname,libkdevelop.so -o libkdevelop.so "kdevelop.dir/dummy.o" 
-L/usr/X11R6/lib -L/usr/src/kde3-HEAD/kdevelop/lib/interfaces 
-L/usr/src/kde3-HEAD/kdevelop/lib/interfaces/extensions 
-L/usr/src/kde3-HEAD/kdevelop/lib/interfaces/external 
-L/usr/src/kde3-HEAD/kdevelop/lib/util 
-L/usr/src/kde3-HEAD/kdevelop/lib/widgets/propeditor -L/opt/kde/lib 
-L/usr/src/qt-copy/lib -lqt-mt -lSM -lICE -lX11 -lXext -ldl -lpthread 
-lkdecore -lkdeui -lkscript -lktexteditor -lkdevinterfaces 
-lkinterfacedesigner -lkdevextensions -lkdevutil -lkdevpropertyeditor

-Wl,-rpath,/usr/X11R6/lib:/usr/src/kde3-HEAD/kdevelop/lib/interfaces:/usr/src/kde3-HEAD/kdevelop/lib/interfaces/extensions:/usr/src/kde3-HEAD/kdevelop/lib/interfaces/external:/usr/src/kde3-HEAD/kdevelop/lib/util:/usr/src/kde3-HEAD/kdevelop/lib/widgets/propeditor:/opt/kde/lib:/usr/src/qt-copy/lib

-lgcc 
 
I have three problems with this approach: 
 
1) how do I link to a shared library which isn't installed yet ? 
I added lines like this one: 
${CMAKE_BINARY_DIR}/lib/interfaces/external/libkinterfacedesigner.so 
 
Now what happens if the shared library isn't named lib*.so, e.g. under 
windows ? Then this probably won't work. 
Should I explicitely add the ${CMAKE_BINARY_DIR}/lib/interfaces/external/ 
to the link path and then simply use 
TARGET_LINK_LIBRARIES(... kinterfacedesigner) ? What is the recommended 
way ? 
Which effect does the rpath-stuff have ? Does is matter where the library 
will be installed to later on ? 
 
2) In kdevelop libkdevelop links to several shared libs and also to some 
static libs. E.g. libkdevinterfaces.a is approx. 500 kb big and the stuff 
contained in it should be contained in the resulting libkdevelop. But 
with the given link command this isn't the case. The resulting 
libkdevelop is only about 6 kb big and doesn't contain the objects from 
the static libs it linked to. 
Is there a way to achieve this ? 
Including the source files directly into libkdevelop wouldn't be optimal, 
since it would require some restructuring in the kdevelop sources. 
 
3) In the kdevelop tree there are two targets "kdevelop": a library 
ADD_LIBRARY(kdevelop ...) and a binary ADD_EXECUTABLE(kdevelop ...) in 
different directories. 
Now I tried to build kdevelop/parts/abbrev/libkdeabbrev.so which is 
intended to link to libkdevelop. So I entered 
TARGET_LINK_LIBRARIES(kdeabbrev kdevelop). 
When compiling, at this point I got the output 
"Jumping to kdevelop/src/ to build kdevelop" which isn't what it should 
do. 
It seems make or cmake thought that since libkdeabbrev.so links to 
(lib)kdevelop(.so) it has to build (the executable) kdevelop before it 
can link libkdeabbrev.so. But this isn't the case, since here kdevelop 
means libkdevelop.so. 
I got around this by specifing the full path and name, but then I have 
problem 1) again. 
 
(And when all this works, I'll probably have to generate fake .la files 
for the plugins, so that they can be loaded using ltdlopen() but I think 
this won't be a big problem...) 
 
Any hints are very much appreciated :-) 
 
Bye 
Alex 
 

-- 
+++ GMX - Die erste Adresse für Mail, Message, More +++

1 GB Mailbox bereits in GMX FreeMail http://www.gmx.net/de/go/mail


More information about the CMake mailing list