How to compile only one file (C ++) in Visual Studio 2012 without a project?

I have many files - sample C ++ code. I open each file and I have to copy the code from the example file to the main.cpp file in some project. Can Visual Studio compile one open file in .cpp without a project?

+4
source share
2 answers

In this case, the easiest way to compile from the command line.

Launch a command prompt window and run the batch file to set environment variables ( %PATH% , etc.) accordingly. On my pc it is

 "C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat" 

Then, to compile foo.cpp to foo.exe , just use

 cl /EHsc foo.cpp 
+5
source
+1
source

Source: https://habr.com/ru/post/1443827/


All Articles