Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding MSVC 2017 to Qt

I want to add the MSVC 2017 compiler correctly inside my Qt 5.13, I know where to add it! But, don't know : "How to? What is required to be filled inside the add compiler's menu?"

I have tried too many things. I have a long long story with Qt's main problem! My main problem is : "module machine type 'x64' conflicts with target machine 'x86'" which appears in the console when I build the Qt application! I am going to include some of the things that I have tried :

  • Tried to build from the Qt app and the Console.
  • Tried all the compilers that are auto-detected from Qt. There are more, but no need to mention the rest. On my default kits, Most of the names were in this order : "Qt 5.13.0 for UWP 64/86-bits (MSVC 2017)". I thought that it must be MSVC 2017, so I tried to setup MSVC 2017 (I have MSVC 2019). I found the compiler's main program which is : "cl.exe". I went to Qt auto-detected compilers, I did not find it! I tried to add it by copying the commands for qmake.exe and jom.exe from another kits that already made for me. However, I put the compiler's type 'custom', because I did not find MSVC. Is that wrong, and what does that differ from the other types?

My next thing to fix (actually try) is this :

Image

The picture above contains the compiler's path and Make's path. I need to find the Make path tool, I think it is required, isn't it? I tried to run the program without Make step, ONLY qmake step. Which led me into another problem when running the program : "An Error has Occured when trying to Build/Deploy your program". I filled the compiler's path correctly, but I don't know how to fill the make path, I don't even know what is make path. Note that Qt is not giving me any result because the make path is not filled correctly!

I hope that everything is described and all the information that you need is already included in the story above!

like image 270
Hasan Shadi Avatar asked Jul 04 '19 11:07

Hasan Shadi


People also ask

How do I add MSVC compiler to Qt?

You specify the compiler to use for each kit in Edit > Preferences > Kits. To add a C or C++ compiler, select Edit > Preferences > Kits > Compilers > Add. Select a compiler in the list, and then select C or C++. To clone the selected compiler, select Clone.

Does Qt support C++ 17?

As mentioned, Qt 6 makes C++17 a requirement in order to adopt its more advanced language features.

Is MSVC better than GCC?

GCC is a fine compiler, and can produce code that has pretty much the same performance, if not better, than MSVC. It is missing some low-level Windows-specific features though.

Where is the MSVC compiler?

More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .


1 Answers

You cannot add MSVC manually to Qt Creator. You do need to have it auto-detected.

Also the mechanisms of detection changes depending on MSVC version and Qt Creator version. So be sure to use the latest version of Qt Creator (4.9.2 at this time) to make sure all your installed MSVC toolchain are detected.

Also given you comment you seem to confuse 64-bit and 32-bit.

x86 means 32-bit and amd64 means 64-bit.

This gives:

  • x86 32-bit compiler that produces 32-bit exe
  • x86_amd64 32-bit compiler that produces 64-bit exe
  • amd64 64-bit compiler that produces 64-bit exe
  • amd_x86 64-bit compiler that produces 32-bit exe

So if you wan to produce 32-bit programs, you can use x86 or amd64_x86. If you want to produce 64-bit programs, you can use amd64 or x86_amd64.

If at some point you want to compile a Qt porgam, but Qt Creator does not recognize your MSVC toolchain, you still have a solution:

  1. Open Qt 5.12.4 (MSVC 2017 64-bit) from the start menu
  2. In the prompt run C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
  3. Run qmake and enjoy
like image 112
Benjamin T Avatar answered Sep 30 '22 15:09

Benjamin T