我正在使用Ubuntu 8.10(Intrepid Ibex),并使用GCC编译C++文件,但是在编译时,GCC会生成一个名为a.out
的可执行文件。如何制作Linux可执行文件?
我正在使用Ubuntu 8.10(Intrepid Ibex),并使用GCC编译C++文件,但是在编译时,GCC会生成一个名为a.out
的可执行文件。如何制作Linux可执行文件?
那个可执行文件是“Linux可执行文件” - 也就是说,它可以在任何最新的Linux系统上执行。你可以使用以下方式将文件重命名为所需的名称:
rename a.out your-executable-name
或者更好的是,使用以下方式告诉GCC输出文件的位置
gcc -o your-executable-name your-source-file.c
请记住,在Linux系统中运行文件之前,您可能需要设置其“可执行位(executable bit)”:
chmod +x your-executable-name
还要记住,在Linux上,文件的扩展名与实际内容很少有关系 - 你的可执行文件可以被命名为something
、something.out
,甚至是something.exe
,只要它是由GCC生成的,并且你对该文件执行chmod +x
命令,你就可以将其作为Linux可执行文件运行。
-rwxrwxr-x
。 - Peter Mortensenmyprog
的可执行文件,可以像这样调用gcc:gcc -c -o myprog something.c
chmod u+x ./a.out
./a.out
*.out
文件是可执行文件。你需要其他类型的可执行文件吗? - notnoopa.out
,不是*.out
。(来自未来的问候!) - Keith Thompsona.out
should already be executable. No need to do anything else. Just run with./a.out
- Max MacLeod