View Single Post
  #3 (permalink)  
Old December 7th, 2006, 11:41 PM
steven_wort steven_wort is offline
Wrox Author
 
Join Date: Dec 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you have multiple OBJ files with a _main defined.

For simple / trivial code samples like this, I find it MUCH easier to compile on the command line. It tecaches me the correct compiler and linker options, and is so much easier to troubleshoot when something goes wrong.

To get started use the Visual Studio Command Prompt (found under Start -> Microsoft Visual Studio <version> -> Visual Studio <version> Tool -> Visual Studio command prompt

Once you have this open navigate to the folder where your source file lives and then use the following command line to compile the sample below. I called mine sample.cpp

cl sample.cpp /c /EHsc

After the compiler is done, then link it using the following example.

cl sample.obj /link


If you want to debug it, then you need a few more options, the following is a comprehensive set of compile and link settings to build a symbol files, assembly listings, and a map file to help with debugging.

cl sample.cpp /c /Zi /MTd /Od /Fdsample.pdb /FAcs /EHsc

cl sample.obj /DEBUG /link /PDB:sample.pdb /OUT:sample.exe /release /DEBUGTYPE:cv /map
If you want to know what all the options stand for, go look them up in the visual studio help files. I usualy search MSDN for compiler options, and that gets me a good hit somewhere in the online version of msdn.

http://msdn2.microsoft.com/en-US/library/9s7c9wdw.aspx

The linker options are the next section below this.

Hope this helps get you going again.



Steve Wort
Co Author "Professional SQL Server 2005 Administration"
Reply With Quote