I have a lot of files - examples code in C++. I open every file and I must copy code from example file to main.cpp file in some project. Can Visual studio compile one opened file in .cpp without project?
Asked
Active
Viewed 7,596 times
4
-
You go back to an ancient copy of VS (6.0 or earlier), or live without. Technically, even then you needed a project -- but if you asked it to compile without a project, it would create one automatically, then compile. Might have added an extra .1 second to the compile cycle, but was otherwise fairly transparent. Now, VS is built with the idea that you need to do things its way, not to support doing what you want. – Jerry Coffin Nov 03 '12 at 15:15
2 Answers
5
It's probably easiest to compile from the command line in this case.
Start a Command Prompt window and run the batch file to set up the environment variables (%PATH%
etc.) appropriately. On my PC this is
"C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat"
Then to compile foo.cpp
into foo.exe
, just use
cl /EHsc foo.cpp

j_random_hacker
- 50,331
- 10
- 105
- 169