I would like to compile in VS2008 x64 from bat file.
When I compile in VS2008 32 bits I call vsvars32.bat.
What do I need to call to compile in x64?
Nowadays the recommendation is not to use vsvar32.bat and use SetEnv.cmd instead to set up your build environment. Pass the /x64 argument to select a 64 bit build environment. This MSDN page has some more information about SetEnv.cmd.
A simple way is to go in the directory : "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64" and execute the file : "vcvarsamd64.bat"
You need to install "X64 Compilers and Tools" feature in your VS2008 IDE.
Please try adding "X64 Compilers and Tools" feature via Control Panel >> Add/Remove Programs (For Vista or later OS, please go to "Programs and Features").
After entering Visual Studio 2008 Maintenance Mode, please expand "Visual C++" node >> click "X64 Compilers and Tools" >> click "Update" button.
Then you can enter "Visual Studio 2008 Command Prompt (x64)"
Hope this helps!
Visual Studio will install shortcuts to launch command prompts that setup an appropriate environment for triggering builds. You can see where the shortcut for the x64 Command Prompt points to by right clicking on it and checking out its target property. It typically points to:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
There is more information here: https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx
Related
I would like to compile a C++ program via Visual Studio command line tools. I would like to target the executable for 32 bit Windows XP. Tried compiling it the usual way, using x86 Native Tools Command Prompt for VS 2019, but it doesn't work on Windows XP, though runs fine on my Windows 10 machine.
Steps I take:
Open x86 Native Tools Command Prompt for VS 2019.
cd to the project directory. There I'll have 2 folders sources and headers, which shall contain .cpp and .h files respectively.
Execute command cl sources\*.cpp /EHsc /D_WIN32_WINNT=0x050103 /I headers /I <path to boost> /link /libpath <path to boost>\boost_1_77_0\bin\x86\lib\libboost_program_options-vc142-mt-s-x32-1_77.lib /out:exec_xp.exe (the project uses the boost library).
Tried this, but it doesn't work. /D \"_USING_V110_SDK71_\" seems to do nothing, and the /SUBSYSTEM:WINDOWS,5.01 piece isn't recognized by the compiler.
I have learnt from this Microsoft page that we should install deprecated Toolset to compile for WinXP. I went ahead to Visual Studio Installer and installed the C++ Windows XP Support for VS 2017 (v141) tools [Deprecated], as said in the tutorial.
But what now? How can I use this Toolset? I can't find it anywhere on my computer, let alone use it! Visual Studio Installer says it's located under C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools, but it's too vague.
UPD:
Tried with msbuild /p:PlatformToolset=v141_xp, getting this error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(439,
5): error MSB8020: The build tools for v141_xp (Platform Toolset = 'v141_xp') cannot be found. To build using the v141_
xp build tools, please install v141_xp build tools. Alternatively, you may upgrade to the current Visual Studio tools
by selecting the Project menu or right-click the solution, and then selecting "Retarget solution"
Which suggests, the compiler doesn't see the v141_xp toolset. I wonder why? It's installed for sure, I did it via the Visual Studio Installer.
I suggest you could try to set the PlatformToolset property:
msbuild myProject.vcxproj /p:PlatformToolset=…
For more details, I suggest you could refer to the Doc:MSBuild command-line reference
I am using Visual Studio with C++.
For a particular reason, I now need to use CMake to build a piece of the project. I would like to tell CMake to use the same compiler I normally use with Visual Studio.
How can I find the exact cl.exe compiler executable path used by Visual Studio? There are a few of these on my machine.
Inside VS in menu Tools > Command Line select Developer Command Prompt then run where cl. You can also select Developer PowerShell and run Get-Command cl or specifically (Get-Command cl).Source
You can also open start menu, type developer and open the desired terminal
With the newer version, it probably lies in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64 or C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86 (for 32-bit). 14.26.28801 will be different in your PC though
I have a project that has only ever lived in Visual Studio 2017. It's a C++ dll, and up until this point I've had no problem building it from within the Visual Studio GUI. However now I'm trying to set up automation that will build the project on the command line and upload the output files to a desired location. Here's what I've tried so far (in a brand new Command Prompt):
cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>
vcvarsall amd64
cd C:\Users\me\development\MyProject
msbuild MyProject.slnl (or msbuild MyProject\MyProject.vcxproj)
And this gives me the error output
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Platform.targets(57,5):
error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build
using the v141 build tools, please install v141 build tools. Alternatively, you
may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Retarget solution".
[C:\Users\dev\development\MetaReme\MetaReme\MetaReme.vcxproj]
Let me reiterate that I've been successfully building within Visual Studio 2017 targeting the v141 toolset, it's just on the command line I'm having trouble. Within my Visual Studio Installer application I have the VC++ 2017 v141 toolset checked. I've looked on the filesystem and within C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\ there is no v141 folder.
Thanks!
Thanks guys! I was following https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line which says "By default, these tools are installed in drive:\Program Files (x86)\Microsoft Visual Studio version\VC\bin.". Obviously these docs are outdated... I was able to get it to work with the following commands
cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvars64
cd "C:\Users\me\development\MyProject"
msbuild MyProject.sln
It says in the first part of the paragraph in the mentioned article:
In Visual Studio 2017, these are located in the VC\Auxiliary\Build subdirectory of the Visual Studio installation directory. In Visual Studio 2015, these are located in the VC, VC\bin, or VC\bin\architectures subdirectories of the installation directory, where architectures is one of the native or cross compiler options.
As you are using Visual Studio 2017, they should be in VC\Auxiliary\Build, like you found out.
Another way to find the correct .bat files would be through the command prompt shortcuts mentioned in the same article. First locate them by expanding start->Visual Studio Year, right click and find their location. Then check the location they are pointing to.
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
I need to be able to compile a visual studio 2005 c++ project from the command line. I have found this post in the SOF archives but it does not seem to help me solve my problem. I am not able to find neither msbuild or vcexpress. Can someone point me to where they must be or is there a different command for visual studio 2005?
What I need is to create a batch file that does the compiling.
Click Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt.
To open the Windows SDK Command Prompt window (Windows SDK version 6.1 or later):
Click Start, point to All Programs, point to Microsoft Windows SDK , and then click SDK Command Prompt or CMD Shell.
And read How to: Compile a Native C++ Program from the Command Line in Visual Studio
You're looking for cl.exe.
But, ehm, batch file? Don't you mean makefile?