Results 1 to 6 of 6

Thread: CMake, MinGw and failng linking

  1. #1
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default CMake, MinGw and failng linking

    Hi,
    I've downloaded and installed Qt5.5 precompiled with MinGw 4.92.
    After that I tried to compile my old projects (created with Qt for VisualStudio).
    This binary compiles - fails during linkage.
    Qt Code:
    1. || [ 42%] Built target log4cpp
    2. || [ 45%] Built target tools_lib
    3. || [ 46%] Automatic moc for target PhoneticNumberSystem
    4. || [ 46%] Built target PhoneticNumberSystem_automoc
    5. || [ 47%] Linking CXX executable PhoneticNumberSystem.exe
    6. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CAppSettings.cpp.obj):CAppSettings.cpp:(.text+0xd7c): undefined reference to `_imp___ZN7QObjectC2EPS_'
    7. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CAppSettings.cpp.obj):CAppSettings.cpp:(.text+0xe72): undefined reference to `_imp___ZN7QObjectD2Ev'
    8. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CAppSettings.cpp.obj):CAppSettings.cpp:(.text+0xebc): undefined reference to `_imp___ZN7QObjectD2Ev'
    9. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CDataThread.cpp.obj):CDataThread.cpp:(.text+0x1d3): undefined reference to `_imp___ZN4QDirC1ERK7QString'
    10. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CDataThread.cpp.obj):CDataThread.cpp:(.text+0x1f8): undefined reference to `_imp___ZN4QDirD1Ev'
    11. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CDataThread.cpp.obj):CDataThread.cpp:(.text+0x35f): undefined reference to `_imp___ZN4QDirD1Ev'
    12. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CDataThread.cpp.obj):CDataThread.cpp:(.text+0x500): undefined reference to `_imp___ZN4QDir9separatorEv'
    13. || CMakeFiles\PhoneticNumberSystem.dir/objects.a(CDataThread.cpp.obj):CDataThread.cpp:(.text+0x7a6): undefined reference to `_imp___ZN4QDir9separatorEv'
    To copy to clipboard, switch view to plain text mode 
    Here what CMakeLists.txt for main binary looks like http://pastebin.com/Bk5Jq0ZR
    g++ (GCC) 4.8.1
    In system environment I added variable QT_DIR=d:\Qt\Qt5.5.1\5.5\mingw492_32
    and added it to PATH like => %QT_DIR%;%QT_DIR%\bin;%QT_DIR%\include;%QT_DIR%\li b

    Obviously, linker can't find proper objects in proposed libraries. Now, should I rebuild entire Qt to fit G++ 4.8? Should I install more recent MinGw version with newer g++? Or some other CMake settings changes are needed?

  2. #2
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: CMake, MinGw and failng linking

    Try to change environment var-name QT_DIR to QTDIR.

  3. #3
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CMake, MinGw and failng linking

    Didn't help.
    CMake finds Qt, as compilation is success. But it fails in linking with precompiled libraries.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: CMake, MinGw and failng linking

    It looks to me as though you might be missing a #define QT_DLL as part of your compilation and linking options. Look at your old VS project file and I think you'll find that. So it will need to be set for CMake as well via a compiler and linker -D flag most likely.

  5. #5
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CMake, MinGw and failng linking

    When I changed QT_DIR variable (and in result PATH) I didn't delete CMake build rules/cache. It didn't matter how many times I run cmake or make or make clean - inside Makefiles path to Qt libraries were leading to previously set MSVC folder.
    I've deleted build folder, generated it once again and this time binaries compiled and linked without a problem.
    Thank you all - case closed.

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: CMake, MinGw and failng linking

    That is one of those CMake gotchas that you really have to watch out for. It burns me every time I'm starting a new CMake project and am still playing around with settings.

Similar Threads

  1. How build Qt with CMake & MinGW in windows?
    By jennal in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2014, 02:19
  2. CMake and Qt on Windows using MinGW
    By woodtluk in forum General Discussion
    Replies: 1
    Last Post: 26th December 2010, 20:04
  3. Cmake and opengl - linking error
    By harnz in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2010, 19:00
  4. Problem when linking a Qt Unit Test with CMake
    By NoRulez in forum Qt Programming
    Replies: 6
    Last Post: 10th June 2010, 18:30
  5. Linking to wrong version of Qt in Cmake
    By Matt Smith in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2007, 11:39

Tags for this Thread

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.