在Ubuntu中运行C程序

本文转载自: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 

 

posted @ 2020-07-23 15:31  夜下青灯  阅读(1873)  评论(0编辑  收藏  举报