在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