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

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

Related

Visual Studio 2015 Installer doesn't install cl.exe

I had installed Visual Studio 2017 on my machine with VC2015.3 C++ compiler toolset. The VC14 compiler is now located in C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin\cl.exe
Now, when I install Visual Studio 2015 and select to install "Common Tools for Visual C++ 2015" there is no cl.exe in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin as expected and as it always have been.
It's just like the installer "know" that I have already VC14 compiler installed (through VS2017) and skips it completely.
What is the issue here?

Where is the Microsoft Visual Studio Community executable located?

I just installed it but I don't know where it is. Can anyone help me? I've looked in a lot of places but I still don't know.
Look for devenv.exe, it should be at:
Visual Studio Community 2015
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
Visual Studio Community 2017
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE
Visual Studio Professional 2017
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
For VS2019 it's now at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
I would say instead of looking at a predefined location for the installation which might change in future what you should do is as follows -
Search for visual studio in apps search
Right click and select "Open file location"
Once you have this shortcut, Right click on it and select and open properties and see the target field. This is your executable path.
For me it is -
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe"
Due to this link https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line
Visual Studio location could be
\Program Files\Microsoft Visual Studio\Version\Offering or
\Program Files (x86)\Microsoft Visual Studio\Version\Offering
where Offering is one of Enterprise, Professional or Community, Version is 2019, etc
For VS 2022 it's now at (Program Files not Program Files x86):
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE
For VS 2020
"C:\Users\Username\AppData\Local\Programs\Microsoft VS Code\Code.exe"

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

Can't find the Visual Studio 2012 Express for Web installation

I am pretty sure I installed VS 2012 Express on my new laptop a month ago. I even posted on Facebook about how I didn't like the default themes because the window borders were too light in color.
Now, I can't seem to find the VS 2012 Express installation. Where should I look?
I've looked for devenv.exe or any exe under C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common\IDE and in C:\Program Files\Microsoft Visual Studio 11.0\Common\IDE.
Okay, I found it. The exe name is VWDExpress.exe and it is located at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common\IDE
If you are using the Ultimate version go to
C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE
and look for "devenv" with visualStudio Icon .
I had the same problem. I found it in
Local Disk > Program Files 86 > Common7 > IDE > WDExpress
It wasn't an .exe when I found it, it was an application that I launched.

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.

Resources