How do you change kits in Qt to target an x86 machine? - c++

I'm currently working on a project in QtCreator. I'm using a library that is x86 based but my current project is targeting an x64 architecture. The obvious solution is to change my project to target an x86 architecture. However, I have no idea how to do this.
I've gone into the appropriate window to configure a new Qt kit. This kit uses the MVCC x86 compiler. I then select this as my default project. After running the new qmake, I attempt to build the project yet get the same error regarding using a 32 bit library in a 64 bit project.
So my question: how do I apply a new kit in Qt? I assume I should be able to click the 'Open Build and Run Kit Selector'and select the kit, however, this just gives me the options of select the x64 kits.
Any idea?

First make sure the kit is added in the Build & Run menu of the Options panel. I think you have performed this step already:
Then go to the Projects tab after you have loaded your project and click on "Add Kit". There you should be able to select your newly added kit:
Finally, you should then be able to select it from the kit selector:

Related

“Could not determine which ”make“ command to run. Check the ”make“ step in the build configuration.” Qt creator

I installed Qt Creator 5.10.1 and when I built the project I had a error : "Could not determine which ”make“ command to run. Check the ”make“ step in the build configuration.”.
I have already install Qt on another PC and I saw this question "Could not determine which "make" command to run. Check the "make" step in the build configuration." Qt creator
but in Tools > Options > Build & Run > Kits I have lot of Desktop Qt 5.10.1 so he have 1.
Sorry for my english as I'm french and I 13 so my skill is limited
https://www.dropbox.com/s/lg17a54pdgj9923/screen.png?dl=0
You can see the selected build kit in the Build Kit Selector located at the bottom left of your window (button with the hammer image).
You can also manage any of the Build Kits if you go to Tools > Options > Build & Run.
For any build kit in Qt, you need to have the following components:
Device - You can build your application or your desktop/local computer or a remote computer or device with a different or same kind of processor.
Compiler - Specify the location of a compatible C++ compiler here. Clicking on manage takes you to the Compilers tab where you can add as many compilers as you want. If you are on Windows, you will most likely have a MinGW compiler installed along with Qt at this location - C:\Qt\Tools\MinGW\bin\gcc.exe. You can also select a compiler installed with Visual Studio which will be a MSVC compiler.
Qt Version - The last thing you need to specify is the Qmake builder which is in Qt Version. You will need to select this with the appropriate C++ compiler that you previously selected in this build kit. If you have a MinGW C++ compiler, then specify a path for a MinGw qmake.exe and if it is a MSVC compiler then select a MSVC based qmake.exe. On Windows, all your qmake.exe's will be located at C:\Qt\<Qt-version>\<compiler-version&type>\bin\qmake.exe.
Keep in mind that if you are building the project for a different processor or operating system, you will need an appropriate compiler and Qmake selected.
Once you select these properly (and select that build kit in selector), your project will build properly.

How to change/configure desired compiler in Qt creator? i.e. switch between MSVC/Mingw or g++/clang++

I am aware about how to add compiler in Qt Creator. However my Qt always chooses MSVC compiler. How to set MinGW (built-in or external) instead of MSVC?
Couldn't find any post which can help a newbie to know how to change the compiler of desired preference. My current system is Windows, however information on Linux (g++ <--> clang++) is also welcome.
Following is the way with Qt 5.9:
While configuring a new project, select only those compilers/kits which are required;
For 64-bit system, get the latest MinGW and install in a suitable path; While installing MinGW64, you may select "posix threads", and not "win32 threads" to allow threading related libraries
Go to Tools > Options > Build & Run > Compilers and add a manual C++ compiler. Choose the path of where you installed C:/MinGW64/bin/g++.exe (name it something like "MinGW64"); Similarly you may add C compiler as well with C:/MinGW64/bin/gcc.exe; Click 'Apply'
In the same dialog box, select the Debuggers tab and similarly add C:/MinGW64/bin/gdb.exe (name it like "MinGW64 Debugger); Click 'Apply'
In the same dialog box, select the Qt Versions and add a new Kit with MinGW64 like name; However I couldn't find an appropriate qmake.exe for it; Hence, I decided to use the same qmake.exe, which came with built-in 32 bit MinGW within Qt package (not sure about this as of now)
In the same dialog box, now select the Kits tab and add a new Manual kit; You may also follow the way the default MinGW32 bit compiler is configured; Configure Compiler, Debugger and Qt Version for this newly named kit; Click 'Ok'
On the left pan of Qt creator, click on "Projects" tab, and go to "Build & Run" option there; To avoid confusion, you may disable all the kits which are not required; Just keep the relevant kit and click "Build" with either "Debug" or "Release" setting

How can I setup my computer for windows application development environment with Qt 3.3.0?

Today I am interested to develop some windows applications and installed Qt 3.3.0 also. I choose Qt Widgets Application and leave the create in location to be default i.e. C:\Users\ComputerName\Documents I don't checked on Use as default project location checkbox and click on next button. Now here in Kits tab it said to No valid kits found and next button is disabled. I don't have installed anything else than Qt. So how can I setup my computer for windows application development environment with Qt 3.3.0 ?
In Tools->Options "Build&Run" section you need to make sure that at least one kit is defined. To do that you also need to have at least one "Qt version" and "Compiler" defined in your QtCreator. Perhaps you've installed only the IDE without mingw?

LNK1112: module machine type 'x64' conflicts with target machine type 'X86': Qt creator

I have a application running on linux which I am trying to import on windows. I have set up all the libraries and also made changes to the .pro file. Now when I try to build the project I get this error:
error: LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
I am not sure what is causing this issue.I am using the 32-bit Qt creator. I know there are a couple of links which talk about changing the project properties but all those are related to changing them in Visual Studio. I am using Qt creator and running the project through the Qt UI. So I am not sure what changes have to be done for the project properties through Qt if this has to be resolved.
I had the same problem but my scenario was a little different, I was targeting x64 architecture, and when I changed it to x86 I got this error, it took me some time to figure out that I had to re-build the project to match CPU architectures.
It is obvious that you are compiling for 32 bits target but some of your libraries are 64 bits, which much likely you already know.
Make sure that Qt Creator is using the correct compiler (VC++, MinGW) and machine model (32, 64 bits) for your particular project.
Open your project
File -> Open File or Project... -> ... -> yourproject.pro
Check that Qt Creator auto-detected a compiler that meet the machine model of your libraries.
Tools -> Options -> Build & Run -> Kits
Select (define) the desired Build Kit and other settings for your project.
Select "Projects" from the left panel.
In the upper pane is shown the associated Kits for your project.
You can add more Kits with the "Add Kit v" button.
Hovering the mouse over the associated Kits, a little arrow is shown.
Clicking on it provides operations to apply to the Kit.
You can change or remove the Kit from your project following this little arrow.
Generate a new Makefile based on the new information.
Build -> Run qmake
Rebuild from scratch.
Build -> Rebuild All
I see this post was a while ago but I just ran across the same issue and this may be the solution for someone else that runs into this again. I have a different setup but I got the same error.
My application is running on Windows with Visual Studio 2019 and I needed mine to work properly in both x64 and x86 configurations. I ran into this error when I tried running my project in x86. Here was my solution.
Go to your project's Properties page
Project -> <ProjectName> Properties
Check your Qt Project Settings
Configuration Properties -> Qt Project Settings
Make sure you are pointing to the correct Qt Installation under
General -> Qt Installation
You can check this by checking your Qt Options in the Qt VS Tools Extension for VS. If you don't have it make sure you add it. Mine says "Qt5.13.2" which for me is pointing to the x64 build of Qt but it needs to be pointing to the x86 build.
To change this you need to create a Qt Version that points to the x86 build and change the Qt Installation in Qt Project Settings to point to that one.
Extensions -> Qt VS Tools -> Qt Options
Under Qt Versions tab check the Qt Version that your Property Sheet was pointing to. If it is not correct for your configuration here is where you can create another one.
Press the Add button to "Add New Qt Version"
Build Host: Windows
Version name: <give it a name> (I did "Qt5.13.2_86")
Path: <Path to correct build> (mine was "C:\Qt\Qt5.13.2\5.13.2\msvc2017")
compiler: msvc (automatically sets to this when selecting Windows for the Build Host)
Press OK
Now go back to your Qt Installation under Qt Project Settings in your Configuration Properties in your Project's Property sheet and make it point to the correct Qt Version (Mine was from "5.13.2" -> "5.13.2_86").
This was my solution for a different problem but the same error.
I had the same problem in Qt Creator when I was trying to build for a x64 machine using MSVC 2017. Somehow the linker would always be configured with a x86 target machine and fail.
I noticed that link.exe from a /x86/ directory was being called. Somewhere the path was "stuck". After searching for a while I found several incorrect paths in /MY PROJECTS BUILD DIRECTORY/CMakeCache.txt file. The header of this file indicated that it was generated by CMake: C:/Qt/Tools/CMake_64/bin/cmake.exe.
After replacing all the relevant occurences of 'x86' with 'x64' in that file, and rebuilding the project, the problem disappeared.
I had the same problem, i installed Qt 6.3.1 MSVC2019 but i got multiple linking error related to the architecture "LNK4272: library machine type 'x64' conflicts with target machine type 'x86'".
i solved the problem by changing the compiler of the kit
goto : edit -> preferences -> kits -> goto the MSVC2019 kit -> Compilers (C and C++) in my case they was "Microsoft Visual C++ Compiler 16.11.32630.194 (amd64_x86)" change it to amd64 (or your correct architecture)

How to create x64 version of native console project?

I have a VS2008 solution with several libraries and 4 console apps. All build and run correctly in 32 bit mode. The libraries all build and run in x64 mode in another solution with a C# app and a C++/CLI interface layer.
Now I need to build an x64 flavor of the 4 console apps (functional and unit tests for the libraries).
On the Configuration Manager dialog, the Platform dropdown for these 4 projects offers only Win32 as an option. (x64 is also there for the libraries). The Edit and New options are there but do not seem to offer a way to create an x64 choice.
Presumably VS2008 is disallowing x64 for some reason. Is there some other attribute or option I need to set first?
EDIT: Trying to create a new platform in Configuration Manager fails because there already is an x64 platform. It is available to all the library projects.
If you don't get "x64" in the New Platform combo then the x64 C/C++ compilers are not installed. They are not by default (remarkably) unless you started the VS2008 install with the Custom option and turned the option on. Rerun setup.exe to add them, don't forget to rerun the SP1 setup as well. You can double-check by verifying if the vc\bin\amd64 folder is present in the VS install folder, that's the home of the 64-bit build tools.
Another trap exists when the x64 platform already exists in the solution file, brought in by the managed projects. Be sure to untick the "Create new solution platform" checkbox in the dialog.
It's well supported. You just need to add the platform before it appears in drop-down lists:
Build/Configuration Manager
Active Solution Platform
<New...>
x64
If you are using VS 2008 Express, it will not include x64 support.
EDIT: If the configuration already exists on the solution, but not on the project, use this sequence:
Build/Configuration Manager
Go to the line with the project, column Platform
Drop-Down list, <New...>
x64