954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

compiling .cpp in visual studio

Is it possible to compile a single .cpp (not a project) in visual studio 2008? Also will using visual studio cause problems executing code on a unix system?

I am making my first c++ "hello world" program and I am attempting to use visual studios. Am I going to have to make a project for every little thing I program?

It almost seems like a joke to have resource.h, stdafx.h, app.ico, app.rc, AssemblyInfo.cpp, stdafx.cpp, and Hello.cpp just for "hello world" lol.

Thanks for your help and advice on the matter. =)

PopeJareth
Light Poster
29 posts since Jun 2009
Reputation Points: 11
Solved Threads: 3
 

AFAIK, you have to make a project first, and then add the main.cpp file as a source. Unless you want to do it manually using the Visual Studio 2008 command prompt and "cl.exe" to compile.

William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
 

>>Is it possible to compile a single .cpp (not a project) in visual studio 2008
No.

>>Also will using visual studio cause problems executing code on a unix system?
If you mean run the *.exe on *linux, the answer is that it cannot. You will have to compiler it on the machine you want to run it on, in this case a *nix computer. The binaries are not compatible between the two operating systems.

>>It almost seems like a joke to have resource.h, stdafx.h, app.ico, app.rc, AssemblyInfo.cpp, stdafx.cpp, and Hello.cpp just for "hello world" lol.

You can create an empty project and add your own *.cpp file(s) to it.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

>It almost seems like a joke to have resource.h, stdafx.h, app.ico, app.rc, AssemblyInfo.cpp, stdafx.cpp, and Hello.cpp just for "hello world" lol.

You don't need all those files, when making a new project, remember to choose "Empty Project" in the additional options while in the wizard.

William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You