使用GCC构建Linux可执行文件 [英] Build An Linux Executable Using GCC
问题描述
我正在使用Linux Ubuntu Intrepid Ibex并使用GCC编译C ++文件,但是当我编译时,gcc使得 a.out
文件,这是可执行文件,但是如何我可以制作Linux可执行文件?感谢!
I'm using Linux Ubuntu Intrepid Ibex and compiling C++ files with GCC, but when I compile, gcc makes a.out
file, that is the executable, but how I can make Linux executables? Thanks!
推荐答案
该可执行文件是一个Linux可执行文件 - 也就是说,它可以在任何最新的Linux系统上执行。您可以将文件重命名为您要使用的文件
That executable is a "Linux executable" - that is, it's executable on any recent Linux system. You can rename the file to what you want using
rename a.out your-executable-name
或更好,告诉GCC使用它的输出文件的位置
or better yet, tell GCC where to put its output file using
gcc -o your-executable-name your-source-file.c
请记住, Linux系统会让你运行这个文件,你可能需要设置它的可执行位:
Keep in mind that before Linux systems will let you run the file, you may need to set its "executable bit":
chmod +x your-executable-name
另外请记住,在Linux上,文件的扩展名与它的实际内容很少有关系 - 可执行文件可以被命名为某些东西
, something.out
,甚至 something.exe
,只要它是由GCC生成的,并且你在文件上执行 chmod + x
,就可以将它作为Linux可执行文件运行。
Also remember that on Linux, the extension of the file has very little to do with what it actually is - your executable can be named something
, something.out
, or even something.exe
, and as long as it's produced by GCC and you do chmod +x
on the file, you can run it as a Linux executable.
这篇关于使用GCC构建Linux可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!