如何将库路径添加到./configure命令?

我想./configure链接到一个库和一些包含文件。 我的库存储在/home/foo/sw/lib/ ,我的文件存储在/home/foo/sw/include

./configure --help抛出以下内容:

一些有影响的环境变量:

  CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, eg -L if you have libraries in a nonstandard directory  LIBS libraries to pass to the linker, eg -l CPPFLAGS (Objective) C/C++ preprocessor flags, eg -I if you have headers in a nonstandard directory  CPP C preprocessor 

我尝试了各种组合:

 ./configure --prefix=/home/foo/sw -I -L ./configure --prefix=/home/foo/sw -I=/home/foo/sw/include -L=/home/foo/sw/lib/ ./configure --prefix=/home/foo/sw -I/home/foo/sw/include -L/home/foo/sw/lib/ etc.. 

但我似乎无法正确使用语法。 如果有人可以帮助我,那将非常感激。 谢谢!

你错过了意思

一些有影响的环境变量

所以你将它们设置为环境变量; configure通过检查配置文件和环境来确定LDFLAGS和CPPFLAGS。 你可以像这样设置它们……

 export CPPFLAGS='-I/home/foo/sw/include' export LDFLAGS='-L/home/foo/sw/lib/' ./configure 

或作为一个class轮:

 env CPPFLAGS='-I/home/foo/sw/include' LDFLAGS='-L/home/foo/sw/lib/' ./configure 

请注意,您可能无法使用/home/foo/sw/lib/下的子目录

你把你的库放在/home/foo/sw/lib/bar/可能会显示一个lib not found错误。

但是,您可以使用多个条目:

LDFLAGS="-L/home/foo/sw/lib -L/home/foo/bar/lib"