本文转载自:https://www.cnblogs.com/xiaomingzaixian/p/8561790.html

1、创建C文件  test.c

指令:touch test.c

2编写test.c文件

vim test.c

#include <stdio.h>

int main()

{

printf(“welcome to here !!! \n”);

return 0;

}

3、执行C文件当C程序包含其他的库的时候比如:

#include <stdio.h>

#include <pthread.h>

int main()

{

printf(“welcome to here !!! \n”);

return 0;

}

此时编译指令为:gcc -pthread test.c

有多少库就在gcc后面加空格-XXX,还有库就再在-XXX再空格-XXX库

此指令回车之后会生成默认名为a.out的可执行文件,若是想生成指定名称的可执行文件则其指令为:

gcc -o test test.c

注:此指令中-o test 表示生成的可执行文件的名称为test 

 

版权声明:本文为1149825709qq原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/1149825709qq/articles/13366607.html