Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to get exe file of compiled cpp code? Can I use it in a system not containing cpp compiler?
Posted
Comments
[no name] 19-Sep-12 11:58am    
You look in your output directory and yes.
Richard MacCutchan 19-Sep-12 12:02pm    
If it's already compiled why do you need a compiler?
Santhanameinstein 19-Sep-12 12:12pm    
Can I use the output file of cpp as application file which can be opened by simply double clicking ?(i am using turbocpp) thanks in advance

One of the compilation stage functions is to check for errors, another one is to create object files (*), depending on the good the compiler is you can get better or worse diagnostics on your code.

After a successful compiling stage then you can link. After linking then you can get an exe file.

You cannot execute the cpp file in a computer without linking it previously.

To get more information check those links:
http://en.wikipedia.org/wiki/Compiler[^]
http://en.wikipedia.org/wiki/Linker_(computing)[^]

Good luck.

(*) Improved after receiving a 100% correct comment from CPallini. Thank you! ;)
 
Share this answer
 
v3
Comments
CPallini 19-Sep-12 13:07pm    
Compile isn't for checking errors, compile is for producing object files (or fully executables, in some cases). Checking for errors is just one step of the compilation process.
Joan M 19-Sep-12 13:16pm    
Corrected already, thank you, you are right.
As already suggested by Joan Murt, in order to produce an executable file you have (generally speaking) to:
  1. Compile the source file. The product of the a succesfull compilation is the corresponding object file
  2. link the object file with all the necessary libraries. The product of a succesfull linking step is the executable file


The syntax for compiling and linking depends on the compiler or on the IDE (Integrate Development Environment) you are using. Might be simple like
g++ mysource.cpp

for a very simple application on Linux OS, or more complex.
You should really check the documentation of your development tools.

Executables files don't need the C++ compiler for running. That is you may deploy your executable on a target machine lacking of the C++ compiler.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900