Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
How to get exe file of compiled cpp code? Can I use it in a system not containing cpp compiler?
Posted 19-Sep-12 5:55am
Comments
Wes Aday at 19-Sep-12 11:58am
   
You look in your output directory and yes.
Richard MacCutchan at 19-Sep-12 12:02pm
   
If it's already compiled why do you need a compiler?
Santhanameinstein at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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! Wink | ;)
  Permalink  
v3
Comments
CPallini at 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 Murt at 19-Sep-12 13:16pm
   
Corrected already, thank you, you are right.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 420
1 CHill60 410
2 Sergey Alexandrovich Kryukov 384
3 PIEBALDconsult 235
4 BillWoodruff 190


Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100