visual studio 2005 32 bit and 64 bit building from command promt - visual-studio

I want to build a project automatically from command prompt. I am using Visual Studio 2005. I want to build for x86 and x64 platforms. I tried running "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" myproject.sln /Build "Release|x86" but its not working.

Use "Release|Win32" and "Release|x64".

Related

CMake -G Ninja on Windows specify x64

I am using CMake on Windows with Ninja generator
cmake -G Ninja ..
This uses the default Windows x86 toolchain.
How to specify x64 using the Ninja generator?
PS: I know how to generate x64 with Visual Studio
cmake -G "Visual Studio 12 2013 Win64 ..
You have to set the compiler environment accordingly before calling Ninja generation. If you have Visual Studio 2013 installed at the standard installation path you call:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
cmake.exe -G "Ninja" ..
Edit: Thanks for the hint from #Antwane: "Or simply run CMake command from a Microsoft Visual Studio Command Prompt (x64). A shortcut to this prompt is located in Start Menu".
The naming varies over the Visual Studio versions:
When I then look into the generated CMakeCache.txt file I see:
...
//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
...
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING= /machine:x64
...
//Path to a program.
CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/link.exe
...
When I tried to run cmake on command line in Windows, trying to use Ninja and targetting the Visual Studio 14.0 compiler (2015), it kept picking up on other installed compilers (in my case gcc) instead.
The following command line worked:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=140 ..
This answer assumes you have Visual Studio installed and have installed all the proper C++ libraries and what not when you installed visual studio.
Start typing in "x64 Native Tools" in your start menu. Open the file location and you will see a certain amount of shortcuts. On my visual studio installation I only have compilers for the x86/x64 architecture.
Anyway now that you have opened the file location you will be presented with a bunch of developer command prompt shortcuts:
PS C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC> ls
Directory: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2/16/2021 8:12 PM 2139 x64 Native Tools Command Prompt for VS 2019 Preview.lnk
-a--- 2/16/2021 8:12 PM 2197 x64_x86 Cross Tools Command Prompt for VS 2019 Preview.lnk
-a--- 3/3/2021 9:01 PM 2139 x86 Native Tools Command Prompt for VS 2019 Preview.lnk
-a--- 2/16/2021 8:12 PM 2197 x86_x64 Cross Tools Command Prompt for VS 2019 Preview.lnk
PS C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC>
Let me explain what each one does:
x64 Native Tools Command Prompt for VS 2019 Preview
Use x64 compiler to compile for a x64 machine
x64_x86 Cross Tools Command Prompt for VS 2019 Preview
Use x64 compiler to compile for a x86 machine
x86 Native Tools Command Prompt for VS 2019 Preview
Use x86 compiler to compile for a x86 machine
x86_x64 Cross Tools Command Prompt for VS 2019 Preview
Use x86 compiler to compile for a x64 machine
In my opinion the last 2 are useless in the modern day. And have caused multiple CI crashes on our servers. So we only use 64 bit binaries.
Anyway you double click on one of the shortcuts:
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.10.0-pre.1.0
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview>
And bang you will have a command prompt loaded with an environment CMake can recognize. This is because the PATH environment variable now contains the compilers and what not.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview>echo %PATH%
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.29917\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\LLVM\bin;C:\Program Files\Git\cmd;C:\Program Files\PowerShell\7\;C:\Program Files\CMake\bin;D:\Installations\Python\Scripts\;D:\Installations\Python\;C:\Users\juanr\AppData\Local\Microsoft\WindowsApps;D:\Installations\Microsoft VS Code\bin;C:\Users\juanr\AppData\Local\GitHubDesktop\bin;D:\Git\ninja;;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\Llvm\x64\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
Now you can run cmake with Ninja:
NOTE: In this example I'm manually specifying the path to Ninja. You can also just add Ninja to your path. And depending on your visual studio installation this may already be done for you. If you download the "C++ CMake tools for Windows" you have Ninja added to your path for you. You even get CMake added for you.
cmake -S . -B build -G "Ninja" -DCMAKE_MAKE_PROGRAM=C:/foobar/ninja.exe

Visual Studio C++ and OpenMPI in windows: missing files.h

I've just correctly installed Visual Studio Express C++ and OpenMPI.
I've added the path to PATH variable:
C:\Program Files\OpenMPI_v1.5.5-win32\bin;
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE;
C:\Program Files\Microsoft Visual Studio 10.0\VC\include
and I've written a simple program in MPI on visual c++ express.
The problem is that when I try to compile from prompt dos
mpicxx -o mpi mpi01.cpp
it tells me that there are a lot of missing files.h (no such file od directory) which are all inside
C:\Program Files\Microsoft Visual Studio 10.0\VC\include
But, as I've just said, I've included this in PATH.
Why does it miss them all?
Your "prompt dos" should be the one you get when you launch the Visual Studio "Developper Command prompt". Shortcut located in your Start Menu -> Programs -> Microsoft Visual Studio -> Visual Studio Tools

How to debug x64 with Visual Studio?

I'm trying to create my first Silverlight application. It seems that it can't be debugged because Visual Studio 2010 uses the x86 'Remote Debugger'. It that I also have the x64 bit version installed in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64
But I can't find how I'm supposed to make VS 2010 use
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64
instead of
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x86
Thank you.

CMake Visual Studio Differences?

When I went to compile a project with CMake using MSVC++, I noticed something. CMake asked me to identify which copy of Visual Studio I wanted to use, and it presented me with the choices:
Visual C++ 2010
Visual C++ 10
Visual C# 2010
Visual C# 10
What is the difference between 2010 and 10?
The internal version number for VS2010 is version 10. Lucky coincidence. Version 11 won't be on your machine until 2012. Or later.
For creating a VS2010 project and compiling it from cmd, these are the options you could use:
cmake -G "Visual Studio 11 Win64" "%myProject%\src"
CD %HOMEDRIVE%\Windows\Microsoft.NET\Framework64\v4.0.30319
msbuild %myProject%\build\ALL_BUILD.vcxproj /detailedsummary /property:PlatformToolset=v110 /p:TargetFrameworkVersion=v4.5.1 /clp:ErrorsOnly /p:Configuration=Debug
msbuild %myProject%\build\ALL_BUILD.vcxproj /detailedsummary /property:PlatformToolset=v110 /p:TargetFrameworkVersion=v4.5.1 /clp:ErrorsOnly /p:Configuration=Release

VC++ cl.exe -- DLL not found

I added the bin directory of the VS2010 (not SP1) C++ compiler to my PATH variable on Windows XP. When i try to run it, it tells me that a DLL was not found.
I added this line to my PATH:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;
Update: it still fails when I cd to the bin directory above, and then run the compiler
Can you help me out?
Run the VS command prompt shortcut or the batch file it points to, such as:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
to set up an appropriate environment including the path.
By the way, mspdb100.dll lives in C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE. But run the shortcut/batch file anyway - it does more than set up the correct path.
add Microsoft Visual Studio 10.0\Common7\IDE to your Path variable, than close cmd prompt and open it. now it will work.
Running the VS command prompt takes care of setting up the environment. Also, ensure that you are running the command prompt as an admin.
Installing Visual Studio 2010 SP1 C++ Compiler Setup fixed this issue for me. Visual Studio 2010 SP1 C++ Compiler install
I faced the same issue when I tried to run a 32 bit exe I built, on a 64 bit machine.
"mspdb100.dll couldn't be found by cl.exe "
Visual Studio 2010(the version I currently use) builds a 32 bit exe by Default.To create a 64 bit executable, just change the setting from Win32 to x64 in the dropdown box at the top of VS and build.This will build for you a 64 bit executable and solve your problem.

Resources