Jeff Lance
Jeff Lance

Reputation: 31

minGW CPP G++ Proper Command to Compile

I installed the following: MINGW32_NT-6.1 i686 Msys

I am working with the command line. Wrote the "typical" HelloWorld.cpp program.

IF I compile with: cpp HelloWorld.cpp -o HelloWorld.exe COMPILE is good. (18k) BUT execution fails: 16 bit MS-DOS Subsystem. NTVDM CPU error

IF I compile with: g++ HelloWorld.cpp -o HelloWorld.exe COMPILE is good. (48k) Execution is good.

I cannot determine the BEST way to execute the compile and what the difference is between the methods. Any suggestions? or good references? THANKS.

Upvotes: 3

Views: 448

Answers (1)

Viktor Latypov
Viktor Latypov

Reputation: 14467

"cpp" is the "C PreProcessor", not the compiler. So you're just getting something strange in HelloWorld.exe

Execute the "type HelloWorld.exe" and see what it gives. It shouldn't even be a binary file - just a long text file with all the "#includes" and "#defines" replaced.

To your question - the second way is "right", because you actually invoke the compiler/linker and produce a valid executable. The first "way" is a valid command, but it has almost nothing to do with compilation and linking.

Upvotes: 3

Related Questions