Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Can i use the output file of cpp as application file which i can open by simply double clicking ? (i am using turbocpp) thanks in advance
Posted 19-Sep-12 7:23am
Comments
Wes Aday at 19-Sep-12 12:30pm
   
"output file of cpp as application file" make no sense at all. A cpp file is just a text file so you can associate it with whatever editor you want.
Sergey Alexandrovich Kryukov at 19-Sep-12 14:49pm
   
Of course. I tried to provide a very basic sketch of what's the life cycle. Please see my answer -- how do you think, can it be understood? :-)
--SA
Wes Aday at 19-Sep-12 14:51pm
   
Oh it's understood, by me whether the OP is capable of understanding is the question. :-) This has already been explained to the OP before he reposted this. I do not think that he has the basic understanding of what a program is or how a computer works.
Sergey Alexandrovich Kryukov at 19-Sep-12 14:54pm
   
Got it :-) Probably you knew that I'm asking about my answer -- is it clear enough to be understood by OP with his background. You understand why I'm not sure...
--SA
Sergey Alexandrovich Kryukov at 19-Sep-12 14:55pm
   
And yes, this is all about basic understanding what a computer and the code do in principle, so I'm afraid I wasted some of my time...
--SA
Wes Aday at 19-Sep-12 14:58pm
   
I would not say that at all. Maybe you said it just different enough that the OP would understand then what was previously explained to him. If not, then it might help someone else some other time.
Sergey Alexandrovich Kryukov at 19-Sep-12 15:15pm
   
Good point. Thank you, Wes.
--SA
Sergey Alexandrovich Kryukov at 19-Sep-12 14:53pm
   
[Misplaced --SA]
Santhanameinstein at 19-Sep-12 12:51pm
   
Compiling and executing the source code everytime,is this only to get the output of a cpp program?
Sergey Alexandrovich Kryukov at 19-Sep-12 14:28pm
   
I'm afraid you are not ready to a short answer yet, because you need to get familiar with a good number of concepts you have no idea about... Perhaps I'll try...
--SA
Wes Aday at 19-Sep-12 14:50pm
   
You have to compile and link the cpp file to get an exe. And you have already been told this. I do not know why you are asking this again.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The most basic life cycle of the code is something like this:

  1. Write/modify a set of source code files;
  2. Compile all of them in certain order reflecting their dependency; you only need to compile only those not already compiled and not modified since previous compilation;
  3. Link the object files and libraries obtained on previous step and taken from 3rd parties (if any);
  4. Obtain the executable file(s) from the previous step, usually EXE and DLLs and run the EXE;
  5. When you perform (4), the system loader starts the new process each time you run the EXE (so there could be several processes started to execute the same application); the application is terminated by the user, by the OS or by the process itself (by user command or not) if it is programmed this way;
  6. If modification of the application is not required, go to (4);
  7. If modification is required, go to (1).

The dependencies can be resolved automatically bases on some project file and file stamps; in this case the step (1) may include modification of a project file(s).

I only covered the basics of the life cycle typical for a C or C++ application. I also did not cover a multi-project solution, where you, basically, produce several executable files with some DLLs shared by several EXEs. The file naming *.exe or *.dll is just a Windows convention, the names can be different and are different in different systems.

There are different technologies and platforms where the life cycle is very different. For example, with the .NET platform, the life cycle is fundamentally different, intermediate files and libraries are different.

I did not cover the details on what compiler, linker and loader do and why they are separate; how the DLLs are loaded by the system loader or by the application code and how they can be used. The operations of each of these parts are not trivial at all. The parts of developer's code arranged in memory, names are resolved, all addresses are obtained and shifted according to positions of all parts in memory, and a lot more. Covering all this matter would take a really long article. You can read about it. This is the phase where you need at least a bit of systematic education, not just a set of cookbook result.

And yes, your assumptions you formulated in your question do not make sense; they are based on some misconceptions. You need to learn how things basically work before going to any esoteric fields.

—SA
  Permalink  
v6
Comments
pasztorpisti at 19-Sep-12 20:35pm
   
5ed, for sacrificing your time to write this tutorial :-)
Sergey Alexandrovich Kryukov at 19-Sep-12 20:37pm
   
:-) :-)
Thank you very much.
--SA
Andrewpeter at 19-Sep-12 21:15pm
   
Very good, vote 5.
Sergey Alexandrovich Kryukov at 19-Sep-12 23:51pm
   
Thank you, Andrew.
--SA

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

  Print Answers RSS
0 Maciej Los 184
1 Sascha Lefévre 120
2 Abhinav S 104
3 Sergey Alexandrovich Kryukov 94
4 Richard MacCutchan 90
0 Sergey Alexandrovich Kryukov 6,628
1 OriginalGriff 6,298
2 Peter Leow 2,534
3 Maciej Los 2,492
4 Abhinav S 2,378


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2015
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