hakuna matata
hakuna matata

Reputation: 3327

Compile single C++ file in Visual Studio 2010

I want to compile a single file in c++ using Visual Studio 2010. I created a new file, not a project, and wrote some "hello world" code and I want to compile it and run it. How to do so? I've searched here and in Google, I got things like F7 or F5 nothing worked.

Upvotes: 2

Views: 12330

Answers (3)

charles borlase
charles borlase

Reputation: 21

In Visual Studio 6.0, you could load up a single CPP file, with a main(), and compile it. Can't remember if this was taken away in Visual Studio 2008 or 2010, but it's gone.

It used to be easy to fire up a new instance, paste in some test code an just run it. Now it takes creating or using a dummy project, as others above have noted.

Not hard, just less handy than before.

Upvotes: 2

dreamlax
dreamlax

Reputation: 95365

You can follow this guide from MSDN to compile standalone C++ files without an IDE.

Upvotes: 4

user1149224
user1149224

Reputation:

Probably for simple tests editing your source file in some editor like Notepad or Metapad and building from the command line with something like:

cl /EHsc /W4 /nologo YourSource.cpp

would be just fine (faster than starting up VS2010 IDE, create new project, etc.)

Upvotes: 1

Related Questions