Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When i try to compile project in CLion with Qt5 lib, take this errors

When i try to compile project in CLion with Qt5 lib, take this errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 421 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WayzzZ
    wrote on last edited by
    #1

    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function main': D:/cpp_projects/QtTests/main.cpp:7: undefined reference to __imp__ZN12QApplicationC1ERiPPci'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:9: undefined reference to __imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:10: undefined reference to __imp__ZN7QWidget12setFixedSizeEii'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:12: undefined reference to __imp__ZN11QPushButtonC1ERK7QStringP7QWidget' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:15: undefined reference to __imp__ZN7QWidget4showEv'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:16: undefined reference to __imp__ZN12QApplication4execEv' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN11QPushButtonD1Ev'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN7QWidgetD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN12QApplicationD1Ev'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN11QPushButtonD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN7QWidgetD1Ev'
    D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN12QApplicationD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QString::QString(char const*)':
    D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qstring.h:833: undefined reference to __imp__ZN7QString16fromAscii_helperEPKci' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QWidget::setGeometry(int, int, int, int)':
    D:/vcpkg/installed/x64-windows/include/qt5/QtWidgets/qwidget.h:857: undefined reference to __imp__ZN7QWidget11setGeometryERK5QRect' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QTypedArrayData<unsigned short>::deallocate(QArrayData*)':
    D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qarraydata.h:239: undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    C 1 Reply Last reply
    0
    • W WayzzZ

      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function main': D:/cpp_projects/QtTests/main.cpp:7: undefined reference to __imp__ZN12QApplicationC1ERiPPci'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:9: undefined reference to __imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:10: undefined reference to __imp__ZN7QWidget12setFixedSizeEii'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:12: undefined reference to __imp__ZN11QPushButtonC1ERK7QStringP7QWidget' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:15: undefined reference to __imp__ZN7QWidget4showEv'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:16: undefined reference to __imp__ZN12QApplication4execEv' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN11QPushButtonD1Ev'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN7QWidgetD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN12QApplicationD1Ev'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN11QPushButtonD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN7QWidgetD1Ev'
      D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to __imp__ZN12QApplicationD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QString::QString(char const*)':
      D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qstring.h:833: undefined reference to __imp__ZN7QString16fromAscii_helperEPKci' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QWidget::setGeometry(int, int, int, int)':
      D:/vcpkg/installed/x64-windows/include/qt5/QtWidgets/qwidget.h:857: undefined reference to __imp__ZN7QWidget11setGeometryERK5QRect' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function QTypedArrayData<unsigned short>::deallocate(QArrayData*)':
      D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qarraydata.h:239: undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
      collect2.exe: error: ld returned 1 exit status
      ninja: build stopped: subcommand failed.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Your project needs to link against the Qt libraries.
      Since CMake seems to be involved you are probably missing lines like

      find_package(Qt5 COMPONENTS Widgets REQUIRED)
      
      1 Reply Last reply
      0
      • W Offline
        W Offline
        WayzzZ
        wrote on last edited by
        #3

        To be clear, the Cmake file looks like this

        image.png

        1 Reply Last reply
        0
        • W Offline
          W Offline
          WayzzZ
          wrote on last edited by
          #4

          I found a solution to the problem, it only works if you switch the CMake-profile Toolchain to Visual Studio.
          and Generator to Visual Studio 17 2022.

          C 1 Reply Last reply
          0
          • W WayzzZ

            I found a solution to the problem, it only works if you switch the CMake-profile Toolchain to Visual Studio.
            and Generator to Visual Studio 17 2022.

            C Offline
            C Offline
            ChrisW67
            wrote on last edited by ChrisW67
            #5

            @WayzzZ Yes, you need the tool chain you build with to match the libraries you link with.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved