![如何设置编译器特定的标准头#include 路径?](https://linux22.com/image/171280/%E5%A6%82%E4%BD%95%E8%AE%BE%E7%BD%AE%E7%BC%96%E8%AF%91%E5%99%A8%E7%89%B9%E5%AE%9A%E7%9A%84%E6%A0%87%E5%87%86%E5%A4%B4%23include%20%E8%B7%AF%E5%BE%84%EF%BC%9F.png)
告诉两个编译器寻找它们的#include
头文件的聪明方法是什么?
我的标准编译器在标准 Linux 86x64 系统上运行gcc
(当前为 v9.3)。现在我想编译一些东西tcc
并将其安装在本地用户目录中。
我怎么知道tcc
去哪里寻找#include
路径呢?我预计它会在
/home/user/lib/tcc/v0.9/include
或者/home/user/lib/tcc/v0.9/lib/tcc/include
答案1
我如何告诉 tcc 在哪里寻找
#include
路径?
使用该-I
选项,就像使用 gcc 或 clang 一样:
从man tcc
:
-Idir Specify an additional include path. Include paths are searched in the order they are specified. System include paths are always searched after. The default system include paths are: /usr/local/include, /usr/include and PREFIX/lib/tcc/include. (PREFIX is usually /usr or /usr/local).
我不认为 tcc 对<...>
和"..."
include 形式有任何区别。
另外,如 中所述man tcc
,您可以使用tcc -vv
来显示默认路径。在我的系统上,这显示:
tcc version 0.9.27 (x86_64 Linux)
install: /usr/lib/x86_64-linux-gnu/tcc
include:
/usr/lib/x86_64-linux-gnu/tcc/include
/usr/local/include/x86_64-linux-gnu
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
libraries:
/usr/lib/x86_64-linux-gnu
/usr/lib
/lib/x86_64-linux-gnu
/lib
/usr/local/lib/x86_64-linux-gnu
/usr/local/lib
libtcc1:
/usr/lib/x86_64-linux-gnu/tcc/libtcc1.a
crt:
/usr/lib/x86_64-linux-gnu
elfinterp:
/lib64/ld-linux-x86-64.so.2