Results 1 to 2 of 2

Thread: CMake and Qt on Windows using MinGW

  1. #1
    Join Date
    Mar 2010
    Posts
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default CMake and Qt on Windows using MinGW

    Hi there

    I tried to use CMake for a small Qt project.
    Here is my CMalkeLists.txt
    Qt Code:
    1. # set project's name
    2.  
    3. PROJECT(TeXular)
    4. cmake_minimum_required(VERSION 2.8)
    5.  
    6. SET(CMAKE_BUILD_TYPE Release)
    7.  
    8. # enable warnings
    9. # ADD_DEFINITIONS( -c -g -Wall -frtti -fexceptions -mthreads -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc)
    10. SET(CMAKE_CXX_FLAGS "-Wall")
    11.  
    12. # this command finds Qt4 libraries and sets all required variables
    13. # note that it's Qt4, not QT4 or qt4
    14. FIND_PACKAGE( Qt4 REQUIRED )
    15.  
    16. # by default only QtCore and QtGui modules are enabled
    17. # other modules must be enabled like this:
    18. #SET( QT_USE_QTXML TRUE )
    19.  
    20. # add some useful macros and variables
    21. # (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
    22. INCLUDE( ${QT_USE_FILE} )
    23.  
    24. # with SET() command you can change variables or define new ones
    25. # here we define SAMPLE_SRCS variable that contains a list of all .cpp files
    26. # note that we don't need \ at the end of line
    27. SET( TEXULAR_SRCS
    28. ./src/main.cpp
    29. ./src/MainWindow.cpp
    30. ./src/TableModel.cpp
    31. )
    32.  
    33. # another list, this time it includes all header files that should be treated with moc
    34. SET( TEXULAR_MOC_HDRS
    35. ./src/MainWindow.h
    36. ./src/TableModel.h
    37. )
    38.  
    39. # some .ui files
    40. SET( TEXULAR_UIS
    41. ./ui/MainWindow.ui
    42. )
    43.  
    44. # and finally an resource file
    45. # SET( TEXULAR_RCS ./src/rc/sample.qrc)
    46.  
    47.  
    48. # and finally this will run moc:
    49. QT4_WRAP_CPP( TEXULAR_MOC_SRCS ${TEXULAR_MOC_HDRS} )
    50.  
    51. # this will run uic on .ui files:
    52. QT4_WRAP_UI( TEXULAR_UI_HDRS ${TEXULAR_UIS} )
    53.  
    54. # this command will generate rules that will run rcc on all files from TEXULAR_RCS
    55. # in result TEXULAR_RC_SRCS variable will contain paths to files produced by rcc
    56. #QT4_ADD_RESOURCES( TEXULAR_RC_SRCS ${TEXULAR_RCS} )
    57.  
    58.  
    59. # we need this to be able to include headers produced by uic in our code
    60. # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
    61. INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
    62.  
    63. # here we instruct CMake to build TEXULARexecutable from all of the source files
    64. ADD_EXECUTABLE( texular ${TEXULAR_SRCS} ${TEXULAR_MOC_SRCS} ${TEXULAR_RC_SRCS} ${TEXULAR_UI_HDRS} )
    65.  
    66. # last thing we have to do is to tell CMake what libraries our executable needs,
    67. # luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:
    68. TARGET_LINK_LIBRARIES( texular ${QT_LIBRARIES} )
    69.  
    70. INSTALL_TARGETS( /bin texular)
    To copy to clipboard, switch view to plain text mode 

    Then I run:
    Qt Code:
    1. cmake -G"MinGW Makefiles"
    2. mingw32-make.exe
    To copy to clipboard, switch view to plain text mode 

    Everything builds without error.
    But if I launch my application I get an error :

    The procedure entry point _Z17qt_message_output9QtMsgTypePKc could not be located in the dynamic link library QtCore4.dll

    If a check the binary with Dependency Walker and compare with an other binary (created with a qmake makefile) I see that there is Mingw10.dllmissing.

    How do I tell cmake to link against Mingw10.dll?
    Or is the procedure entry point error not because of missing Mingw10.dll?

    Platform is Win7 64 bit. Qt Version 4.7


    Thanks for your help.

    Cheers LukeS
    Using Qt 4.7
    Developping on Win 7 and XP
    Using Qt Creator, Eclipse and Visual Studio
    Target Platforms Win, Linux and soon OS X

  2. #2
    Join Date
    Mar 2010
    Posts
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: CMake and Qt on Windows using MinGW

    After hours of trying I found the problem.

    I have MikTex installed ( LaTeX Distribution) and the bin directory is added to the PATH environment variable. Since MikTex has a QtCore4.dll in its bin directory my application tried to load this one instead the one in the Qt directory.
    I suppose it didn't work because the dll's have a different version.
    I just put the MikTex path at the end pf the PATH variable and now it works.

    Cheers LukeS
    Using Qt 4.7
    Developping on Win 7 and XP
    Using Qt Creator, Eclipse and Visual Studio
    Target Platforms Win, Linux and soon OS X

Similar Threads

  1. Windows 7 + Qt + mingw 64-bit
    By serge_malo in forum Newbie
    Replies: 0
    Last Post: 30th September 2010, 13:59
  2. CMake Windows console issue
    By IndigoJo in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2008, 23:12
  3. QT 4.2.2 Windows Mingw
    By KaptainKarl in forum Installation and Deployment
    Replies: 3
    Last Post: 4th May 2007, 15:57
  4. Qt with cmake on windows xp
    By Ashish in forum Newbie
    Replies: 1
    Last Post: 6th October 2006, 23:59
  5. qt and mingw can not run on windows 98?
    By evewei in forum Installation and Deployment
    Replies: 4
    Last Post: 26th June 2006, 10:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.