How to compile big c++ project using MsBuild.exe with x64 compiler - c++

I have the big Visual Studio 2015 C++ project and can't compile it on the computer with 12GB RAM (fatal error C1060: compiler is out of heap space).
Command line:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" Project.sln /t:Rebuild /p:Configuration=Release;Platform=x64
I've read this https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx?f=255&MSPPError=-2147217396
and decided to use x64 compiler, but I can't figure out how it can be done using MsBuild.exe (or with another way but without generate make file - it is hard to maintain it because the project frequently changed).
I was tried to call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" before MsBuild.exe, but it doesn't help.

Found solution here: https://msdn.microsoft.com/en-us/library/ee662426.aspx?f=255&MSPPError=-2147217396
Where is the property PreferredToolArchitecture which by default equals x86.
Set it to x64 to use the 64-bit compiler and tools to build your application.
msbuild myProject.vcxproj /p:PreferredToolArchitecture=x64

Related

How do I find the exact compiler executable Visual Studio is calling?

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

How to run Code Analysis on x64 Project in Visual C++?

I am trying to run the code analysis of Visual Studio 2015 on my x64 VC++ project. However I get the following error:
Error C1250 Unable to load plug-in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\localespc.dll'
I am activating the x64 toolset of Visual Studio by running the batch script "vcvarsall.bat amd64" before I start the IDE. Visual Studio is run with the "/useenv" option afterwards.
When I check the VC++ environment variables, I can see that the following path is contained in the PATH variable:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64
How can I tell Visual Studio to use the code analyzer (localespc.dll) from there and not the x86 version which it apparently tries to use (according to the error message).
Thanks a lot for your help!
I was having the same issue with my 64-bit C++ projects. I discovered simply renaming/removing localespc.dll from VC\bin allowed the Code Analysis builds to succeed and still report analysis warnings. It seems if VS doesn't find this dll in the VC\bin directory then it won't add the compiler switch for /analyze:plugin but otherwise passes all the other switches required by the Code Analysis.
Set the following property in your project file: <PreferredToolArchitecture>x64</PreferredToolArchitecture>
This tells Visual Studio to use the 64-bit version of various tools, including code analysis. I found How to make Visual Studio use the native amd64 toolchain helpful on the topic.
Note that renaming localespc.dll no longer solves the problem with Visual Studio 2017. It seems that setting PreferredToolArchitecture is Microsoft's intended way to do this.

cl.exe not found in Visual Studio 2017 [duplicate]

I'm trying to compile a cuda test program on Windows 7 via Command Prompt,
I'm this command:
nvcc test.cu
But all I get is this error:
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
What may be causing this error?
You will need to add the folder containing the "cl.exe" file to your path environment variable. For example:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
Edit: Ok, go to My Computer -> Properties -> Advanced System Settings -> Environment Variables. Here look for "PATH" in the list, and add the path above (or whatever is the location of your cl.exe).
For new Visual Studio cl.exe is present in path => C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64
x64 is for 64bit
x86 is for 32bit
Solve this problem by adding this options to nvcc
nvcc x.cu ... -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"
for example my compiler is VS2012. and cl.exe is in this dir
cl.exe is Microsoft's C/C++ compiler. So the problem is that you don't have that installed where the command line can find it.
nvcc is only a front end for the CUDA specific part of the program. It must invoke a full compiler to finish the job. In this case it cannot find the Visual Studio compiler 'cl.exe'
Check paths, nvcc documentation etc.
I see that this is an old question but I recently got this error on my Visual Studio 2012 when I tried to build my CUDA project. Apparently I had changed my CUDA project to the Nov 2012 pack, changing it back to the v110 that it usually is by default fixed this error.
In Visual Studio, left click on the CUDA project, ->properties->Configuration Properties-> General -> Platform toolset, and choose: Visual Studio 2012 (v110).
I could probably get it to work with the Nov 2012 pack, but the CUDA code does not use any of the additional functions of that pack, so it is not necessary. (That pack contains the variadic templates for C++11.)
Solve this problem by adding the path to environment variables, which can vary slightly depending in the version of visual studio installed in your system, and are you using 32bit or 64bit system
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64

How to compile 64Bit DLL in Eclipse CDT (using Windows SDK)?

What I want to be done: Create a 64bit DLL on win7 that interacts with the Windows API including the OLE32.dll.
What I have got:
I am currently stuck. I download Visual Studio 2015 Community Edition. I tried to create a DLL there and on creation it generated everything but no dll. The program did not complain, everything was setup as in the tutorial but no dll file.
So I skipped this and downloaded Eclipse CDT. I set up using the Visual C toolchain and after minor issues I had my DLL generated. So I used Java to fire it up but it complained (I use JNA for integration) and it seams that I have a 32bit DLL.
So I searched the web and read and did stuff but I am totally lost. Since the Visual Studio 2010 Express edition came without a 64bit compiler I am not even sure if the Community edition of Visual Studio supports 64bit dlls this time.
I also have the Windows SDK v7.1 installed. I link to a library file ole32.dll. It contains the method CoCreateInstance which I require. I have to add this manually in order for the compiler to pick it up. If I switch to the 64bit dll version the compiler complains about the CoCreateInstance method can not be linked.
So basically I am lost here. A source on the web gave a work around for the 2010 Express being not able to create x64 DLL and it turned out that the hint was getting windows SDK since it it comes along with a compiler.
Also I noticed that CDT uses Visual Studio 10 files so I guess it is using this compiler.
I set to both compiler and linker the /machine:64 option. But the linker still complains that the obj file from the compiler is 32bit.
Any Ideas?
[Update]
The Compiler prints the following line so basically it is not able to compile 64bit version. Any idea how to replace it? As said it uses the Visual Studio 10 folder but I also have a Visual Studio 12 and 14 folder as well.
cl : Command line warning D9002 : ignoring unknown option '/machine:x64'
Well, I don't think '/machine:x64' is a cl option but it's one of linker option.
If you want to make some dll maybe with windows sdk or visual studio environment.
I am not sure that my solution is fit for yours or not, this is what i did for my 64-bit project to compile with eclipse and windows sdk 7.1.
I have two eclipse IDEs which are 32bit and 64bit neon version.
I choose a 64-bit one. You can check one of my answer about installation here. In my opinion, any version of them will be fine. It is your choice.
First step. run 'Windows SDK 7.1 Command Prompt from the start menu.
then, start my eclipse on the command window after changing 64-bit development level with command as follows.
Second Step. Setting up path variables to my project.
I have my own project with a properties window.
The important variable seems to be both LIB and PATH variable in my point.
I crosschecked this two variable, one was from the windows SDK's prompt window and another was current setting variables after installation.
SDK variables here
My final variables are
LIB:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework64\v3.5;
C:\Windows\Microsoft.NET\Framework\v3.5;;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\X64
PATH:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework64\v3.5;
C:\Windows\Microsoft.NET\Framework\v3.5;;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\VCPackages;;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;;
C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
Third, I modified my linker flag as you see the picture below.
Finally, I compiled my project successfully.
Here is my build log.
Info: Internal Builder is used for build
cl /c /EHs /MD /Zi /nologo /Foutil.obj "..\util.c"
rc /Fo proc_view.res "..\proc_view.rc"
Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /EHs /MD /Zi /nologo /Foprocss.obj "..\procss.c"
link /machine:x64 /debug /nologo /OUT:Systemer.exe FreeList.obj LinkedList.obj proc_main.obj proc_view.res procss.obj util.obj Kernel32.lib Psapi.lib User32.lib
The last one had done with checking if my executable file was 64-bit or 32-bit with a dumpbin command.
That is all.
I think the Eclipse with MinGW or cygwin might be a better option.
I hope this is right for you.

Eclipse CDT can't build - not sure what's wrong (console included)

I'm now going to give c++ a try to see what this language have to offer. I'm having some trouble setting it all up though. I have downloaded Eclipse CDT and followed this guide : http://www.dcs.vein.hu/bertok/oktatas/cpp_by_eclipse/eclipse_for_cpp_on_windows.html#Install_gdb
I am using Windows 7 64bit.
I have never installed a compiler before, and I'm not sure what exactly I am doing wrong. It gives me an "Launch failed. no binary found" error when I try to run my program. However there is no binaries folder. I have tried building, it loads for a while, but nothing really happens.
Any idea what to do? I am completely new at c++ so please be patient and let me know if there's anything I am missing :)
The console in eclipse says the following:
Build of configuration Debug for project Test2 **
Internal Builder is used for build ** cl /c /EHs /MD /Zi /nologo /Fospam.obj ..\spam.cpp Internal Builder: Cannot run program "cl" (in directory "C:\cppworkspace\Test2\Debug"): CreateProcess error=2, Den angivne fil blev ikke fundet Error: Program "cl" is not found in PATH
PATH=[C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x86;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\MinGW\bin] Build error occurred, build is stopped Time consumed: 156 ms.
If you will compile with Eclipse CDT + MingGW Compiler you should use the MinGW toolchain
MingW Toolchain
If you want use Eclipse + Microsoft C++ compiler, need change for "Microsoft Visual C++" toolchain and put in PATH
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
or whatever you have because CL program is there...
The problem is simple enough, Eclipse can't find your compiler.
On the lengthy PATH that is quoted I don't see 'c:\MinGW\bin' so I'm guessing you had problems with step 4 under section install MinGW.
Having said all that I don't think Eclipse is a very good environment for developing C++ and I don't think MinGW is a particularly good compiler. I'd seriously recommend you take a look at Visual C++ 2010 Express, which you can download from here http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express
EDIT
OK now I do see 'c:\MinGW\bin', so apologies for that. I think the likely explanation is that you have selected the wrong 'tool chain'. Eclipse thinks you want to build with Visual C++ but you have downloaded MinGW. But really get Visual C++ 2010 Express and forget about Eclipse, it's much easier.