Click here to Skip to main content
13,288,306 members (51,605 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to get exe file of compiled cpp code? Can I use it in a system not containing cpp compiler?
Posted 19-Sep-12 6:55am
Wes Aday 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
Rate this: bad
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:[^][^]

Good luck.

(*) Improved after receiving a 100% correct comment from CPallini. Thank you! ;)
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 Murt 19-Sep-12 13:16pm
Corrected already, thank you, you are right.
Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
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