简体   繁体   English

在 Linux 终端中编译 C 代码

[英]Compiling C code in Linux terminal

I am using Linux mint 16. I had a code that I change it a bit.我正在使用 Linux mint 16。我有一个代码,我对其进行了一些更改。 I use two following commands in terminal in order to run the code.我在终端中使用以下两个命令来运行代码。 The problem is that it does not give me any error but the changes are not applied, which means it runs the previous version of code.问题是它没有给我任何错误,但没有应用更改,这意味着它运行以前版本的代码。

gcc -std=c99 -c Code.c -o Code.o
./Code

gcc -std=c99 -c Code.c -o Code.o will put the compiled object file in Code.o , not ./Code as you expect it to be.. gcc -std=c99 -c Code.c -o Code.o会将编译后的目标文件放在Code.o ,而不是./Code正如您所期望的那样..

Also, -c tells do not run the linker.此外, -c告诉不要运行链接器。 So effectively you end up with an object file which cannot be run.因此,您最终会得到一个无法运行的目标文件。

gcc -std=c99 Code.c -o Code will produce what you need. gcc -std=c99 Code.c -o Code会产生你需要的东西。

For a complete list of gcc flags either use man gcc or see http://linux.die.net/man/1/gcc有关gcc标志的完整列表,请使用man gcc或参见http://linux.die.net/man/1/gcc

Try尝试

gcc -std=c99 -c Code.c -o Code
./Code

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM