如何获取已编译的cpp代码的exe文件? [英] How to get exe file of compiled cpp code?

查看:143
本文介绍了如何获取已编译的cpp代码的exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取已编译的cpp代码的exe文件?我可以在不包含cpp编译器的系统中使用它吗?

How to get exe file of compiled cpp code? Can I use it in a system not containing cpp compiler?

推荐答案

其中一个编译阶段功能是检查错误,另一个是创建目标文件(* ),取决于编译器的优劣,您可以对代码进行更好或更坏的诊断.

在成功的编译阶段之后,您就可以链接了.链接后,您将获得一个exe文件.

如果未事先链接,则无法在计算机上执行cpp文件.

要获取更多信息,请检查这些链接:
http://en.wikipedia.org/wiki/Compiler [http://en.wikipedia.org/wiki/Linker_(计算) [
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! ;)


请参阅StackOverflow链接 ^ ]
Refer StackOverflow link http://stackoverflow.com/questions/8450121/how-do-i-create-a-exe-from-a-cpp-file-in-code-blocks[^]


正如 Joan Murt 所建议的那样,为了生成可执行文件(通常来说) )到:
As already suggested by Joan Murt, in order to produce an executable file you have (generally speaking) to:
  1. 编译 源文件.成功编译的结果是相应的目标文件
  2. 目标文件与所有必要的库链接起来.完整链接步骤的结果是可执行文件
  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



编译和链接的语法取决于您使用的编译器或IDE(集成开发环境).可能很简单



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


适用于Linux OS上非常简单的应用程序,或更复杂的应用程序.
您应该真正检查开发工具的文档.

可执行文件 t 不需要C++编译器即可运行.也就是说,您可以将可执行文件部署在缺少C++编译器的目标计算机上.


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.


这篇关于如何获取已编译的cpp代码的exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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