Linux 如何为配置脚本指定包含目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3958904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:42:49  来源:igfitidea点击:

How to specify include directory for configure script

c++linuxconfiguration

提问by jakab922

I have a linux system at my workplace with pretty old packages and no root access. I'm compiling packages that I need from source with --prefix=[somewhere in homedir]. My problem is that I just can't find out how to convince configure to look for header files in a specific directory. The source is cpp. I tried with environment variables related to g++and looking up flags and googling but I had no success. Can someone help me solve this?

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

采纳答案by Ignacio Vazquez-Abrams

The normal way to do this is --with-<feature>=<header directory>.

执行此操作的正常方法是--with-<feature>=<header directory>.

回答by Benjamin Bannier

Usually you can pass additional compiler flags inside CXXFLAGS. For gccyou can specify more include directories with -I/some/dir, e.g.

通常你可以在里面传递额外的编译器标志CXXFLAGS。因为gcc您可以使用 指定更多包含目录-I/some/dir,例如

$ ./configure CXXFLAGS="-I/some/dir/"

where /some/dir/contains your headers.

其中/some/dir/包含您的标题。

回答by arpadf

It's better to use CPPFLAGS to specify include directories.

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

./configure CPPFLAGS="-I/your/whatever/includedir"

回答by Benjamin Dobell

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++.

The -I flag specifies an additional include directory to be used during compilation.

-I 标志指定要在编译期间使用的附加包含目录。

Generally it's a good idea to use CPPFLAGS when specifying include directories, that way you know it will be used even if the project has some source that is compiled as C.

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

Of course, there might also be circumstances where you only want the include directory to be used by C or C++, but not both. In which case you would obviously be better served by using CFLAGS or CXXFLAGS instead.

当然,在某些情况下,您可能只希望 C 或 C++ 使用包含目录,而不希望两者都使用。在这种情况下,使用 CFLAGS 或 CXXFLAGS 显然会更好地为您服务。