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. Can't compile project using CLion and CMake

Can't compile project using CLion and CMake

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt6clion-idecmakeerror
37 Posts 6 Posters 10.9k 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.
  • M mingvv
    18 Mar 2021, 08:52

    @jsulm Yes, but using QtCreator I can simply build and launch the project during the development phase. With other IDE to build Qt I cannot. So I’m not sure if this windeployqt.exe is what I need. Maybe I just don’t understand why I need to... But my current goal is simply to build a project using at least Visual Studio.

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 18 Mar 2021, 08:55 last edited by
    #11

    @mingvv said in Can't compile project using CLion and CMake:

    With other IDE to build Qt I cannot

    OK, then this is indeed another issue.
    If you're using Visual Studio then this line is wrong:

    set(CMAKE_PREFIX_PATH D:/Qt/6.0.2/mingw81_64/lib/cmake)
    

    It should point to Qt for Visual Studio, not for MinGW.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    M 1 Reply Last reply 18 Mar 2021, 09:09
    0
    • J jsulm
      18 Mar 2021, 08:55

      @mingvv said in Can't compile project using CLion and CMake:

      With other IDE to build Qt I cannot

      OK, then this is indeed another issue.
      If you're using Visual Studio then this line is wrong:

      set(CMAKE_PREFIX_PATH D:/Qt/6.0.2/mingw81_64/lib/cmake)
      

      It should point to Qt for Visual Studio, not for MinGW.

      M Offline
      M Offline
      mingvv
      wrote on 18 Mar 2021, 09:09 last edited by mingvv
      #12

      @jsulm said in Can't compile project using CLion and CMake:

      @mingvv said in Can't compile project using CLion and CMake:

      With other IDE to build Qt I cannot

      OK, then this is indeed another issue.
      If you're using Visual Studio then this line is wrong:

      set(CMAKE_PREFIX_PATH D:/Qt/6.0.2/mingw81_64/lib/cmake)
      

      It should point to Qt for Visual Studio, not for MinGW.

      I only have this folder. Using MaintenanceTool.exe I also don't see separate components for MSVC.

      I used CMake GUI app to generate projects and solution (.sln), but while trying to compile I have 18 errors in library files. Is that why I have MinGW in CMake?

      J 1 Reply Last reply 18 Mar 2021, 09:11
      0
      • M mingvv
        18 Mar 2021, 09:09

        @jsulm said in Can't compile project using CLion and CMake:

        @mingvv said in Can't compile project using CLion and CMake:

        With other IDE to build Qt I cannot

        OK, then this is indeed another issue.
        If you're using Visual Studio then this line is wrong:

        set(CMAKE_PREFIX_PATH D:/Qt/6.0.2/mingw81_64/lib/cmake)
        

        It should point to Qt for Visual Studio, not for MinGW.

        I only have this folder. Using MaintenanceTool.exe I also don't see separate components for MSVC.

        I used CMake GUI app to generate projects and solution (.sln), but while trying to compile I have 18 errors in library files. Is that why I have MinGW in CMake?

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 18 Mar 2021, 09:11 last edited by
        #13

        @mingvv said in Can't compile project using CLion and CMake:

        Using MaintenanceTool.exe I also don't see separate components for MSVC

        You should. You could try to reinstall Qt.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply 18 Mar 2021, 09:26
        0
        • J jsulm
          18 Mar 2021, 09:11

          @mingvv said in Can't compile project using CLion and CMake:

          Using MaintenanceTool.exe I also don't see separate components for MSVC

          You should. You could try to reinstall Qt.

          M Offline
          M Offline
          mingvv
          wrote on 18 Mar 2021, 09:26 last edited by
          #14

          @jsulm
          Indeed, it has now been possible to install the MSVC version. I have upgraded CMake, but this has not corrected the bugs in the project build:

          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QString::~QString(void)" (__imp_??1QString@@QEAA@XZ) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QString::QString(char const *)" (__imp_??0QString@@QEAA@PEBD@Z) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QEAA@AEAHPEAPEADH@Z) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QApplication::~QApplication(void)" (__imp_??1QApplication@@UEAA@XZ) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::show(void)" (__imp_?show@QWidget@@QEAAXXZ) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::resize(int,int)" (__imp_?resize@QWidget@@QEAAXHH@Z) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QPushButton::QPushButton(class QString const &,class QWidget *)" (__imp_??0QPushButton@@QEAA@AEBVQString@@PEAVQWidget@@@Z) referenced in function main
          2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QPushButton::~QPushButton(void)" (__imp_??1QPushButton@@UEAA@XZ) referenced in function main
          2>main.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl QApplication::~QApplication(void)" (??1QApplication@@UEAA@XZ)
          2>main.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl QPushButton::~QPushButton(void)" (??1QPushButton@@UEAA@XZ)
          2>main.obj : error LNK2001: unresolved external symbol "public: __cdecl QString::~QString(void)" (??1QString@@QEAA@XZ)
          2>D:\QSnake\RelWithDebInfo\QSnake.exe : fatal error LNK1120: 12 unresolved externals
          
          J 1 Reply Last reply 18 Mar 2021, 09:32
          0
          • M mingvv
            18 Mar 2021, 09:26

            @jsulm
            Indeed, it has now been possible to install the MSVC version. I have upgraded CMake, but this has not corrected the bugs in the project build:

            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QString::~QString(void)" (__imp_??1QString@@QEAA@XZ) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QString::QString(char const *)" (__imp_??0QString@@QEAA@PEBD@Z) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QEAA@AEAHPEAPEADH@Z) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QApplication::~QApplication(void)" (__imp_??1QApplication@@UEAA@XZ) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::show(void)" (__imp_?show@QWidget@@QEAAXXZ) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::resize(int,int)" (__imp_?resize@QWidget@@QEAAXHH@Z) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QPushButton::QPushButton(class QString const &,class QWidget *)" (__imp_??0QPushButton@@QEAA@AEBVQString@@PEAVQWidget@@@Z) referenced in function main
            2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QPushButton::~QPushButton(void)" (__imp_??1QPushButton@@UEAA@XZ) referenced in function main
            2>main.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl QApplication::~QApplication(void)" (??1QApplication@@UEAA@XZ)
            2>main.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl QPushButton::~QPushButton(void)" (??1QPushButton@@UEAA@XZ)
            2>main.obj : error LNK2001: unresolved external symbol "public: __cdecl QString::~QString(void)" (??1QString@@QEAA@XZ)
            2>D:\QSnake\RelWithDebInfo\QSnake.exe : fatal error LNK1120: 12 unresolved externals
            
            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 18 Mar 2021, 09:32 last edited by
            #15

            @mingvv Did you try a complete rebuild?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply 18 Mar 2021, 09:48
            0
            • J jsulm
              18 Mar 2021, 09:32

              @mingvv Did you try a complete rebuild?

              M Offline
              M Offline
              mingvv
              wrote on 18 Mar 2021, 09:48 last edited by
              #16

              @jsulm Yes, I cleaned solution and rebuilt. Maybe I generated it wrong with CMake? Is there any build guide for Visual Studio or any hidden features?

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 18 Mar 2021, 09:48 last edited by
                #17

                And make sure that the msvc libs are used during linking.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mingvv
                  wrote on 18 Mar 2021, 09:58 last edited by
                  #18

                  Maybe I should add project additional include directories?

                  @Christian-Ehrlicher said in Can't compile project using CLion and CMake:

                  And make sure that the msvc libs are used during linking.

                  How can I check it? I guess I have default settings, because I didn't change them.

                  P.S. Maybe you know, after how many messages can I post more than once in 10 minutes?

                  1 Reply Last reply
                  1
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 18 Mar 2021, 10:12 last edited by
                    #19

                    @mingvv said in Can't compile project using CLion and CMake:

                    How can I check it?

                    Since you've a msvc project take a look in the linker options. Or use cmake-gui to see the CMake values.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    M 1 Reply Last reply 18 Mar 2021, 10:14
                    0
                    • C Christian Ehrlicher
                      18 Mar 2021, 10:12

                      @mingvv said in Can't compile project using CLion and CMake:

                      How can I check it?

                      Since you've a msvc project take a look in the linker options. Or use cmake-gui to see the CMake values.

                      M Offline
                      M Offline
                      mingvv
                      wrote on 18 Mar 2021, 10:14 last edited by
                      #20

                      @Christian-Ehrlicher If I correctly understood you, I use MSVC linker:
                      CMAKE_LINKER - C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/link.exe

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on 18 Mar 2021, 10:33 last edited by
                        #21

                        I don't care about the linker but about the input for it - do you link against the QtWidget dll for msvc?

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mingvv
                          wrote on 18 Mar 2021, 10:47 last edited by
                          #22

                          Finally solved the problem... The reason turned out to be very stupid - CMake was not specified by MSVC, but by MinGW library and the wrong solution was generated.
                          However, in debug version still does not work (now builds only in release) because dll files with suffix "d" are not included. Should they be installed as separate components? They’re not in the bin directory where exist release dlls.

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mingvv
                            wrote on 18 Mar 2021, 15:44 last edited by mingvv
                            #23

                            I found that I have debug dll files in the MSVC directory, but in the MinGW directory there are only release dlls. This causes bugs in debugging. Do you have files with the "d" suffix in the MinGW directory?

                            1 Reply Last reply
                            0
                            • N Offline
                              N Offline
                              nagesh
                              wrote on 18 Mar 2021, 23:48 last edited by
                              #24

                              @mingvv mingw bin directory is having both release and debug version (with d suffix) of dlls.

                              M 1 Reply Last reply 19 Mar 2021, 07:31
                              1
                              • N nagesh
                                18 Mar 2021, 23:48

                                @mingvv mingw bin directory is having both release and debug version (with d suffix) of dlls.

                                M Offline
                                M Offline
                                mingvv
                                wrote on 19 Mar 2021, 07:31 last edited by
                                #25

                                @nagesh said in Can't compile project using CLion and CMake:

                                @mingvv mingw bin directory is having both release and debug version (with d suffix) of dlls.

                                Thank you for the answer!
                                Did you install them separately (I mean, there is a separate item in the installer? If so, what is it called?)?

                                J 1 Reply Last reply 19 Mar 2021, 07:32
                                0
                                • M mingvv
                                  19 Mar 2021, 07:31

                                  @nagesh said in Can't compile project using CLion and CMake:

                                  @mingvv mingw bin directory is having both release and debug version (with d suffix) of dlls.

                                  Thank you for the answer!
                                  Did you install them separately (I mean, there is a separate item in the installer? If so, what is it called?)?

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 19 Mar 2021, 07:32 last edited by
                                  #26

                                  @mingvv said in Can't compile project using CLion and CMake:

                                  Did you install them separately

                                  Do you mean release and debug? No, those are both installed by default.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  M 1 Reply Last reply 19 Mar 2021, 07:37
                                  0
                                  • J jsulm
                                    19 Mar 2021, 07:32

                                    @mingvv said in Can't compile project using CLion and CMake:

                                    Did you install them separately

                                    Do you mean release and debug? No, those are both installed by default.

                                    M Offline
                                    M Offline
                                    mingvv
                                    wrote on 19 Mar 2021, 07:37 last edited by
                                    #27

                                    @jsulm said in Can't compile project using CLion and CMake:

                                    @mingvv said in Can't compile project using CLion and CMake:

                                    Did you install them separately

                                    Do you mean release and debug? No, those are both installed by default.

                                    Yes. I reinstalled Qt, but debug files never appeared for MinGW (with MSVC all OK). "Qt Debug Information" is not that?

                                    J 1 Reply Last reply 19 Mar 2021, 07:55
                                    0
                                    • M mingvv
                                      19 Mar 2021, 07:37

                                      @jsulm said in Can't compile project using CLion and CMake:

                                      @mingvv said in Can't compile project using CLion and CMake:

                                      Did you install them separately

                                      Do you mean release and debug? No, those are both installed by default.

                                      Yes. I reinstalled Qt, but debug files never appeared for MinGW (with MSVC all OK). "Qt Debug Information" is not that?

                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 19 Mar 2021, 07:55 last edited by
                                      #28

                                      @mingvv said in Can't compile project using CLion and CMake:

                                      but debug files never appeared for MinGW

                                      That's strange. On my machine I have both. How did you install Qt and what version?

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      M 1 Reply Last reply 19 Mar 2021, 08:06
                                      0
                                      • J jsulm
                                        19 Mar 2021, 07:55

                                        @mingvv said in Can't compile project using CLion and CMake:

                                        but debug files never appeared for MinGW

                                        That's strange. On my machine I have both. How did you install Qt and what version?

                                        M Offline
                                        M Offline
                                        mingvv
                                        wrote on 19 Mar 2021, 08:06 last edited by
                                        #29

                                        @jsulm said in Can't compile project using CLion and CMake:

                                        @mingvv said in Can't compile project using CLion and CMake:

                                        but debug files never appeared for MinGW

                                        That's strange. On my machine I have both. How did you install Qt and what version?

                                        Using Qt Online Installer for Windows I installed the default set for Qt 6 as well as an additional component for MSVC.
                                        What I have now (as it looks in MaintenanceTool):
                                        *) Qt -> Qt 6.0.2 -> MSVC 2019 64-bit
                                        *) Qt -> Qt 6.0.2 -> MinGW 8.1.0 64-bit
                                        *) Qt -> Developer and Designer Tool -> Qt Creator 4.14.1 CDB Debugger Support
                                        *) Qt -> Developer and Designer Tool -> Debugging Tools for Windows
                                        *) Qt -> Developer and Designer Tool -> MinGW 8.1.0 64-bit
                                        *) Qt -> Developer and Designer Tool -> CMake 3.19.2 64-bit
                                        *) Qt -> Developer and Designer Tool -> Ninja 1.10.0

                                        J 1 Reply Last reply 19 Mar 2021, 08:26
                                        0
                                        • M mingvv
                                          19 Mar 2021, 08:06

                                          @jsulm said in Can't compile project using CLion and CMake:

                                          @mingvv said in Can't compile project using CLion and CMake:

                                          but debug files never appeared for MinGW

                                          That's strange. On my machine I have both. How did you install Qt and what version?

                                          Using Qt Online Installer for Windows I installed the default set for Qt 6 as well as an additional component for MSVC.
                                          What I have now (as it looks in MaintenanceTool):
                                          *) Qt -> Qt 6.0.2 -> MSVC 2019 64-bit
                                          *) Qt -> Qt 6.0.2 -> MinGW 8.1.0 64-bit
                                          *) Qt -> Developer and Designer Tool -> Qt Creator 4.14.1 CDB Debugger Support
                                          *) Qt -> Developer and Designer Tool -> Debugging Tools for Windows
                                          *) Qt -> Developer and Designer Tool -> MinGW 8.1.0 64-bit
                                          *) Qt -> Developer and Designer Tool -> CMake 3.19.2 64-bit
                                          *) Qt -> Developer and Designer Tool -> Ninja 1.10.0

                                          J Offline
                                          J Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on 19 Mar 2021, 08:26 last edited by
                                          #30

                                          @mingvv I did not yet install Qt6, maybe something is different there.

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          M 1 Reply Last reply 19 Mar 2021, 08:31
                                          0

                                          20/37

                                          18 Mar 2021, 10:14

                                          • Login

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