如何为configure脚本指定include目录

jak*_*922 15 c++ linux configuration

我的工作场所有一个linux系统,包含很旧的包,没有root权限.我正在从源代码编译我需要的包--prefix=[somewhere in homedir].我的问题是我无法找到如何说服configure在特定目录中查找头文件.来源是cpp.我试过与环境变量有关g++并查找标志和谷歌搜索,但我没有成功.有人可以帮我解决这个问题吗?

Ben*_*ier 24

通常您可以在其中传递其他编译器标志CXXFLAGS.因为gcc您可以指定更多包含目录-I/some/dir,例如

$ ./configure CXXFLAGS="-I/some/dir/"
Run Code Online (Sandbox Code Playgroud)

哪里/some/dir/包含你的标题.

  • CXXFLAGS用于C++编译器,因此CFLAGS用于C编译器. (5认同)

Ign*_*ams 17

通常的方法是--with-<feature>=<header directory>.


Ben*_*ell 8

CPPFLAGS = C Preprocessor Flags, these flags will be used for C and C++ compilation.

CFLAGS = C Flags, these flags will be used when compiling C.

CXXFLAGS = C++ Flags, these flags will be used when compiling C++.
Run Code Online (Sandbox Code Playgroud)

-I标志指定在编译期间使用的其他包含目录.

通常,在指定包含目录时使用CPPFLAGS是个好主意,这样您就知道即使项目有一些编译为C的源也会使用它.

当然,在某些情况下,您可能只希望C或C++使用include目录,但不能同时使用两者.在这种情况下,使用CFLAGS或CXXFLAGS显然可以更好地服务.


arp*_*adf 5

最好使用CPPFLAGS指定包含目录。

./configure CPPFLAGS="-I/your/whatever/includedir"
Run Code Online (Sandbox Code Playgroud)