[CMake] Linker problems with compiling static QT lib with cmake

Eric Noulard eric.noulard at gmail.com
Thu Jul 29 11:23:17 EDT 2010


Please do not forget to CC the list.

2010/7/29 Balske at t-online.de <Balske at t-online.de>:
>> Shouldn't you use:
>>
>>TARGET_LINK_LIBRARIES(HelloWorld ${QT_QTGUI_LIBRARY})
>
> Well, if I am _not_ linking statically it works with target_link_libraries(HelloWorld QtGui QtCore) without a problem.
> CMake then seems to link the shared libs though, which as I posted strucks me as strange, since it shouldn t even know where
> my nonstatic qt ist installed. I only told CMake where my static qt lib is located in the configure process.
>
>> note that from the FindQt4 module one can read:
>>
>> "      Typical usage could be something like:
>>
>> find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml REQUIRED )
>> include(${QT_USE_FILE})
>> add_executable(myexe main.cpp)
>> target_link_libraries(myexe ${QT_LIBRARIES})"
>
> Well, that is indeed a first step, now the linker does find all the libs which is good. I get tons of undifend reference errors now:

I did never develop a Qt app myself but I'm sure there is a lot
of people that do with CMake.

You may be missing something I don't know about CMake +Qt,
did you read the full documentation for FindQt4 ?
There are other specifically defined macros:
QT4_WRAP_CPP
QT4_WRAP_UI
QT4_ADD_RESOURCES
QT4_GENERATE_MOC
...

However in this area I cannot help,
and I let people with knowledge about Qt+CMake to help you.


> /home/user/Static_Libs/Qt/lib/libQtGui.a(qapplication_x11.o): In function `sm_setProperty(char const*, char const*, int, SmPropValue*)':
> qapplication_x11.cpp:(.text+0x655): undefined reference to `SmcDeleteProperties'
> qapplication_x11.cpp:(.text+0x68e): undefined reference to `SmcSetProperties'
[...]


> Btw.: I CAN link statically to my qt libs with qmake and it works great, so my QT is definitly setup correctly. I need CMake though because I use an ITK project.

I don't know qmake either :-(


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list