如何使用输出文件作为应用程序文件? [英] How to use output file as application file?

查看:73
本文介绍了如何使用输出文件作为应用程序文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否可以将cpp的输出文件用作应用程序文件,只需双击即可将其打开? (我使用的是turbocpp)在此先感谢

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

推荐答案

最基本的代码生命周期如下所示:

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


  1. 编写/修改一组源代码文件;
  2. 以一定顺序编译所有源代码文件,以反映它们的依赖性;您只需要编译自上次编译以来尚未编译和未修改的那些文件即可;
  3. 链接从上一步获得的并从第三方获得的目标文件和库(如果有的话);
  4. 从上一步获得可执行文件,通常是EXE和DLL,然后运行EXE;
  5. 执行(4)时,每次运行EXE时,系统加载程序都会启动新进程(因此可能会有多个进程开始执行同一应用程序);如果应用程序是通过这种方式编程的,则该应用程序将由用户,操作系统或进程本身(无论是否通过用户命令)终止;
  6. 如果不需要修改应用程序,请转到(4 );
  7. 如果需要修改,请转到(1).

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



依赖关系可以基于某些项目文件和文件标记自动解决;在这种情况下,步骤(1)可能包括修改项目文件.

我仅介绍了C或C ++应用程序典型生命周期的基础.我也没有介绍多项目解决方案,基本上,您会在其中生成带有几个EXE共享的DLL的几个可执行文件.命名* .exe或* .dll只是Windows约定,名称可以不同,并且在不同系统中也不同.

有不同的技术和平台,其生命周期有很大不同.例如,使用.NET平台,生命周期从根本上不同,中间文件和库也不同.

我没有详细介绍编译器,链接器和加载器的作用以及它们为何分开的细节.系统加载程序或应用程序代码如何加载DLL,以及如何使用它们.这些部分中每个部分的操作都不是简单的.开发人员代码的各个部分排列在内存中,解析名称,根据所有部分在内存中的位置获取并移位所有地址,等等.涵盖所有这些问题将花费很长的篇幅.您可以阅读有关它的内容.在这个阶段,您至少需要一些系统的教育,而不仅仅是一组食谱的结果.

是的,您在问题中提出的假设是没有道理的.它们是基于一些误解.在进入任何深奥的领域之前,您需要了解事物的基本工作原理.

—SA



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


这篇关于如何使用输出文件作为应用程序文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆