Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Comments
[no name] 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 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
[no name] 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 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 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

1 solution

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
 
Share this answer
 
v6
Comments
pasztorpisti 19-Sep-12 20:35pm    
5ed, for sacrificing your time to write this tutorial :-)
Sergey Alexandrovich Kryukov 19-Sep-12 20:37pm    
:-) :-)
Thank you very much.
--SA
Andrewpeter 19-Sep-12 21:15pm    
Very good, vote 5.
Sergey Alexandrovich Kryukov 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)



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