在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 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM