Can't compile project using CLion and CMake
-
Since you can't mix (msvc) / should not (mingw) debug and release libs it's dangerous to use Qt release dlls with a debug build of your program.
And this strang install stuff is not needed at all - use windeployqt -
@Christian-Ehrlicher said in Can't compile project using CLion and CMake:
Since you can't mix (msvc) / should not (mingw) debug and release libs it's dangerous to use Qt release dlls with a debug build of your program.
Where can I get debug dll files? I reinstalled Qt, but it didn’t help. Are they at another address?
@Christian-Ehrlicher said in Can't compile project using CLion and CMake:
And this strang install stuff is not needed at all - use windeployqt
What does it do? This utility helps configure Qt for Windows?
And then there’s the question. Can I run Qt project (CMake) using Visual Studio?
-
@mingvv said in Can't compile project using CLion and CMake:
What does it do?
It deploys Qt applications. See https://doc.qt.io/qt-5/windows-deployment.html
Qt debug libs are installed together with release libs if you use Qt Online Installer/Maintenance Tool.
-
@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.
-
@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.
-
@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?
-
@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.
-
@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
-
And make sure that the msvc libs are used during linking.
-
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?
-
@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.
-
@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 -
I don't care about the linker but about the input for it - do you link against the QtWidget dll for msvc?
-
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. -
@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?)?