問題引出:
Linux編譯程序時如果找不到頭文件會提示如下錯誤:
$ gcc test.c -o test test.c:9:16: fatal error: xxx.h: No such file or directory #include<xxx.h>
下面敘述以Ubuntu系統(tǒng)為例。
(免費(fèi)視頻教程分享:linux視頻教程)
解決方法如下:
1、先查找 xxx.h 所在路徑
命令如下:
$ sudo find / -name xxx.h
結(jié)果如下:
/usr/local/include/xxx/xxx.h
2、然后用-I選項(xiàng)把目錄加上編譯即可
命令如下:
$ gcc test.c -o test -I /usr/local/include/xxx
相關(guān)文章教程推薦:linux視頻教程