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

Bla*_*der 65 compiling

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

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

一些有影响的环境变量:

  CC           C compiler command
  CFLAGS       C compiler flags
  LDFLAGS      linker flags, e.g. -L<lib dir> if you have libraries in a 
               nonstandard directory <lib dir>
  LIBS         libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS     (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if 
               you have headers in a nonstandard directory <include dir>
  CPP          C preprocessor
Run Code Online (Sandbox Code Playgroud)

我尝试了各种组合:

./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/
./configure --prefix=/home/foo/sw -I/home/foo/sw/include -L/home/foo/sw/lib/
etc..
Run Code Online (Sandbox Code Playgroud)

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

Rin*_*ind 75

你错过了的意思

一些有影响的环境变量

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

export CPPFLAGS='-I/home/foo/sw/include/'
export LDFLAGS='-L/home/foo/sw/lib/'
./configure
Run Code Online (Sandbox Code Playgroud)

或作为单线:

env CPPFLAGS='-I/home/foo/sw/include/' LDFLAGS='-L/home/foo/sw/lib/' ./configure
Run Code Online (Sandbox Code Playgroud)

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

fe 把你的图书馆放进去/home/foo/sw/lib/bar/可能会告诉你一个lib not found错误。

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

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

  • 也许 CPPFLAGS='-I/home/foo/sw/include:$CPPFLAGS' 以防万一有什么东西;) (7认同)
  • 嗨,林兹温德。我对“LDFLAGS=-L”和“LIBS=-l”之间的区别感到困惑。根据帮助,它们似乎是同一回事。有什么区别吗? (2认同)