[CMake] MinGW - Qt Linking problems

Brad King brad.king at kitware.com
Mon May 5 13:24:37 EDT 2008


Vitor Vasconcelos Araujo Silva wrote:
>     With this, I have missing symbols for all calls to Qt functions. Of
> course, if I add:
> 
> –lQtCore –lQtGui –lQtXml
> 
>      To my linking line, everything links ok.
>     This problem does not occurs on Linux with gcc, but only with MinGW.
> My point is, am I missing some point in my project's configuration?
> 
>     I added my CMakeLists.txt to clarify.
[snip]
> FIND_PACKAGE(Qt4)
[snip]
> TARGET_LINK_LIBRARIES(oigui ${QGAR}
>   ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY}
>   ${MINGW32_LIBS})

There is no check in your CMakeLists.txt file to make sure the libraries
are actually found.  Can you confirm whether they are found?  Try adding

  MESSAGE("QT_QTCORE_LIBRARY=[${QT_QTCORE_LIBRARY}]")
  MESSAGE("QT_QTGUI_LIBRARY=[${QT_QTGUI_LIBRARY}]")
  MESSAGE("QT_QTXML_LIBRARY=[${QT_QTXML_LIBRARY}]")

just before the TARGET_LINK_LIBRARIES line.

By the way, the line

  LINK_DIRECTORIES ( ${QT_LIBRARY_DIR})

should not be needed because the libraries should be found with their
full path available.  Given the full path to a library CMake
automatically handles linking to it.

-Brad


More information about the CMake mailing list