Using Visual Studio 2012's compiler to make Qt applications for Windows XP - c++

I know that since VS2012, Microsoft has stopped the support for Windows XP. There is an update for VS2012 so developers could make applications that are supported by Windows XP. Right now I started learning the Qt library. I use Qt Creator and the compiler that I use is from VS2012. Is there a way to select option in Qt Creator so it can produce a valid 32-bit exe for XP? Or is it better to install on my PC VS2010 and use it's compiler? By the way I'm making the applications on Windows 7 and everything works.

We are currently using VS2012 and taking advantage of the update you mentioned to target our VC++ binaries to Windows XP. It's working fine. In Visual Studio, we do this by going to the project properties, Configuration Properties->General->Platform Toolset and selecting "Visual Studio 2012 - Windows XP (v110_xp)".
Checking the compiler command line options (Configuration Properties->C/C++->Command Line), it seems that the switch which tells the compiler to target XP is the following:
/D "_USING_V110_SDK71_"
And in the link command line options:
/SUBSYSTEM:WINDOWS,5.01
/SUBSYSTEM:WINDOWS,5.02
First one for x86, second one for x64 (use only one). If it's a console application, use these instead:
/SUBSYSTEM:CONSOLE,5.01
/SUBSYSTEM:CONSOLE,5.02
I changed the platform toolset and these went away, so I guess they are what you need. In QtCreator, you should edit the compiler and linker command line options accordingly.
Edit: If that doesn't work, try the instructions from the "Targeting from the Command Line" section on this article.

Related

Qt <codecvt> : No such file directory

I cant use std::wstring_convert in Qt 5.1, because it said me that <codecvt> : No such file directory. What can I do? I don't know... this code is working at the MSVC 2013.
QtCreator is just a front-end that allows you to edit your source files, it does not contain a compiler. On Windows you need either MinGW or Visual Studio to compile code.
If you want to use Qt 5.1 with Visual Studio 2013, you would have to compile Qt yourself. Digia provides builds for Visual Studio 2010 and 2012. You can find the latest version of Qt here or an old release here.
My advice would be to install Visual Studio 2012 and download a VS2012 build of Qt. Then go to Tools > Options > Build & Run > Kits, click the Add button on the right (or modify the existing one as it probably won't work anyway). Set the compiler to "Microsoft Visual C++ compiler 11.0 (amd64)" if you downloaded the 64 bit version of Qt or "(x86)" if you downloaded the 32 bit version.
Then set the debugger to cdb.exe and the Qt version to the one you just downloaded (if you don't see it, go to the Qt Versions tab at the top, add it, click Apply and the go back to Kits and it should be there). Click ok and your kit should be ready! Make sure that you don't have a warning signal that would point out a potential mistake.
Now open your project and go to the Projects tab (Ctrl + 5) and make sure your project is using the correct Kit.
You should now be all set up properly.
Additionally, if you don't want to install Visual Studio 2012 and want (or have to) work with VS 2013, you can use the Qt 5.3 BETA builds located here. Please note that these builds are in beta and shouldn't be used in production code, if you want to use VS2013 with Qt in production code I would recommend to build Qt 5.2.1 with VS2013, it's not that hard but it can take a while.
You are missing this in your project file:
CONFIG += c++11
You need to make sure that your GCC version (brought to you by mingw) supports that feature though. It is possible that you are using an old version where it was not supported.

Enabling MSVC10 Platform toolset in VS2012 64bit project [duplicate]

Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
Here are step by step instructions:
Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.aspx.
64-bit tools are not available on
Visual C++ Express by default. To
enable 64-bit tools on Visual C++
Express, install the Windows Software
Development Kit (SDK) in addition to
Visual C++ Express. Otherwise, an
error occurs when you attempt to
configure a project to target a 64-bit
platform using Visual C++ Express.
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
Ref:
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
And make sure you download the Windows7.1 SDK, not just the Windows 7 one. That caused me a lot of head pounding.
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
For instructions on resolving this, see KB2519277 on the Microsoft Support site.
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
Programming in a 64-bit environment is quite different than 32-bit environment.
Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
You might want to see an article on Microsoft's web site about targeting a 64-bit target but using a 32-bit development machine.
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
Kind regards

'cl' is not recognized as an internal or external command,

I am trying to compile a hello world program in Qt Using Qt Creator.
I am getting 'cl' is not recognized as an internal or external command.
I am using Windows 7 and both VS 2008 and 2010 installed in it.
When I use Mingw it is compiling fine but if use vs 2008 it is giving this error.
After Setting Env Path = ..;..;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin also it is showing the same error.
That error happens because cl isn't in your path. You need to add it there. The recommended way to do this is to launch a developer command prompt.
Quoting the article Use the Microsoft C++ toolset from the command line:
On the desktop, open the Windows Start menu. In Windows 11, choose the All apps button to open the list of installed apps. In Windows 10,
the list is open to the left. Scroll down the list to find and open
the folder (not the app) for your version of Visual Studio, for
example, Visual Studio 2022.
In the folder, choose the Developer Command Prompt for your version of Visual Studio. This shortcut starts a developer command
prompt window that uses the default build architecture of 32-bit,
x86-native tools to build 32-bit, x86-native code. If you prefer a
non-default build architecture, choose one of the native or cross
tools command prompts to specify the host and target architecture.
For an even faster way to open a developer command prompt, enter
developer command prompt in the desktop search box. Then choose the
result you want.
As the article notes, there are several different shortcuts for setting up different toolsets - you need to pick the suitable one.
If you already have a plain Command Prompt window open, you can run the batch file vcvarsall.bat with the appropriate argument to set up the environment variables. Quoting the same article:
At the command prompt, use the CD command to change to the Visual Studio installation directory. Then, use CD again to change to the
subdirectory that contains the configuration-specific command files.
For Visual Studio 2019 and Visual Studio 2017, use the
VC\Auxiliary\Build subdirectory. For Visual Studio 2015, use the VC
subdirectory.
Enter the command for your preferred developer environment. For example, to build ARM code for UWP on a 64-bit platform, using the
latest Windows SDK and Visual Studio compiler toolset, use this
command line:
vcvarsall.bat amd64_arm uwp
From the article, the possible values for the first argument are the following:
x86 (x86 32-bit native)
x86_amd64 or x86_x64 (x64 on x86 cross)
x86_arm (ARM on x86 cross)
x86_arm64 (ARM64 on x86 cross)
amd64 or x64 (x64 64-bit native)
amd64_x86 or x64_x86 (x86 on x64 cross)
amd64_arm or x64_arm (ARM on x64 cross)
amd64_arm64 or x64_arm64 (ARM64 on x64 cross)
I had the same problem.
Try to make a bat-file to start the Qt Creator. Add something like this to the bat-file:
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
"C:\QTsdk\qtcreator\bin\qtcreator"
Now I can compile and get:
jom 1.0.8 - empower your cores
11:10:08: The process "C:\QTsdk\qtcreator\bin\jom.exe" exited normally.
Make sure you restart your computer after you install the Build Tools.
This was what was causing the error for me.
I had the same problem and I solved it by switching to MinGW from MSVC2010.
Select the Project Tab from your left pane. Then select the "Target". From there change Qt version to MinGW instead of VC++.
You will have to set environmental variables properly for each compiler. There are commands on your Program menu for each compiler that does that, while opening a command prompt.
Another option is of course to use the IDE for building your application.
I had this problem because I forgot to select "Visual C++" when I was installing Visual Studio.
To add it, see: https://stackoverflow.com/a/31568246/1054322
I had the same issue for a long time and I spent God knows how much on it until I accidentally figured what to do. This solution worked on windows 10. All you need to do is to add C:\WINDOWS\System32 to Path variable under User Variables in Environmental Variables... Note that if you add this to the system variables, it may also work. But, that didn't work for me.
You can use Command prompt for VS 2010 and then select the path that your boost located. Use "bootstrap.bat", you can successfully install it.
For me, this was related to the scenario described by Smi, with the difference being that vcvarsall.bat itself was failing due to an invalid path.
This was cause by line-breaks within the path, which meant vcvarsall.bat couldn't find the common tools directory for some reason.
I sometimes get this problem when changing from Debug to Release or vice-versa. Closing and reopening QtCreator and building again solves the problem for me.
Qt Creator 2.8.1; Qt 5.1.1 (MSVC2010, 32bit)
I faced this error too, checked that there are multiple versions of common tool variables for visual studio in my environment variables (VS120COMNTOOLS, VS110COMNTOOLS and so on) for different visual studio versions.
I removed the ones I did not need from the environmental variables and the issue was resolved.
I was facing the same issue and tried many solutions but nothing work ( I was using vscode 2017) . I just upgraded vscode to 2022 version and the problem is automatically

visual studio 2008 C++ no x64 platform

I installed Visual Studio 2008 on my Windows 7 x64 laptop together with installation of Service Pack 1.
Now I want to add x64 platform to my C++ solution. But there is no x64 platform available in the configuration manager for my project. I'm sure I manually selected x64 support during the Visual Studio installation and it was installed.
What is wrong with my setup?
If I recall, VS 2008 Pro doesn't install the 64-bit compiler and tools by default. You have to explicitly select them during the installation.
Control Panel -> Uninstall Programs.
Select Visual Studio and click Uninstall/Change.
Wait. Wait some more. Click Next.
Choose Add or Remove Features.
Expand MSVC 2008 -> Language Tools -> Visual C++.
Select X64 Compilers and Tools.
You'll probably need your original installation media.
Once the 64-bit compiler and tools are installed, you should be able to add a 64-bit configuration to your solution.
See "Use Visual Studio to build 64-bit application" for all you need to build x64 apps with Visual Studio 2008.
Visual Studio 2008 only comes with x64 compiler with the Professional editions and higher. You can download the free Windows SDK from MSDN to get the x64 compiler.
If your projects don't have the x64 configuration, just add that configuration via the configuration manager. I don't remember if 2008 created the x64 configuration by default but I suspect not.
I also seem to remember that you can just add the x64 configuration to the solution and it will prompt on whether or not to add it to all of the contained projects but my memory is rusty on that one.
Regardless, once you've got the configurations added, you'll need to modify anything you'd modified before in project settings. Output paths, library dependencies, etc. The New Configuration "Wizard" is pretty dumb.

How to compile a 64-bit application using Visual C++ 2010 Express?

Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
Here are step by step instructions:
Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.aspx.
64-bit tools are not available on
Visual C++ Express by default. To
enable 64-bit tools on Visual C++
Express, install the Windows Software
Development Kit (SDK) in addition to
Visual C++ Express. Otherwise, an
error occurs when you attempt to
configure a project to target a 64-bit
platform using Visual C++ Express.
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
Ref:
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
And make sure you download the Windows7.1 SDK, not just the Windows 7 one. That caused me a lot of head pounding.
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
For instructions on resolving this, see KB2519277 on the Microsoft Support site.
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
Programming in a 64-bit environment is quite different than 32-bit environment.
Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
You might want to see an article on Microsoft's web site about targeting a 64-bit target but using a 32-bit development machine.
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
Kind regards