告诉两个编译器寻找它们的#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