【问题标题】:configure script cannot find libxml2 on mac配置脚本在 mac 上找不到 libxml2
【发布时间】:2020-04-07 19:20:40
【问题描述】:

当我执行时

./configure
...
checking for libxml-2.0... no
configure: error: Library libxml2 not found, install library or build without (using --disable-xml).

我用 brew 安装了 libxml2 并查看了很多文章,但到目前为止没有任何帮助。


更新

./configure --help
Some influential environment variables:
  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
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  libxml2_CFLAGS
              C compiler flags for libxml2, overriding pkg-config
  libxml2_LIBS
              linker flags for libxml2, overriding pkg-config

【问题讨论】:

  • 将lib的位置传递给脚本是否有效?

标签: macos homebrew libxml2 configure


【解决方案1】:

homebrewlibxml2 安装为“仅桶”,这意味着它没有符号链接到普通的/usr/local/include/usr/local/lib 目录...这意味着什么可以在没有帮助的情况下找到它。您可以通过运行获得上述所有信息:

brew info libxml2

如果你运行:

brew ls libxml2

它会告诉你该包中所有文件的完整路径。

如果你也运行:

./configure --help

它应该告诉您需要设置哪些环境变量才能找到 libxml2 所以,有了这最后两条信息,您应该能够弄清楚需要设置什么以及如何设置。


我注意到 homebrewlibxml2 列出了一个 pkg-config 文件:

/usr/local/Cellar/libxml2/2.9.10/lib/pkgconfig/libxml-2.0.pc

也可以通过非特定于版本的符号链接获得:

/usr/local/opt/libxml2/lib/pkgconfig/libxml-2.0.pc

所以,如果你用 homebrew 安装了pkg-config,像这样:

brew install pkg-config

解决方案可能只是将其路径添加到您的PKG_CONFIG_PATH 中:

export PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH

然后重新运行您的 configure 脚本。


注意:只有在安装pkg-config(通过brew之后homebrew 才会为许多受影响的软件包显示pkg-config 相关的“警告”,例如libffi:

==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

不幸的是,由于某种原因,libxml2 似乎并非如此。 (相关自制软件问题:“libxml2 install path”。)

【讨论】:

  • 这个运气好吗?
  • 当我在添加PKG_CONFIG_PATH 后尝试运行它时,它不起作用...将尝试通过设置路径来做一些事情,但我之前尝试过类似的事情但它没有工作。顺便说一句,我已经更新了我的帖子。
  • 你安装pkg-configbrew install pkg-config了吗?
  • 好的,我错过了我需要安装它,现在它可以工作了!非常感谢
  • 优秀 :-) 祝你的项目好运!
猜你喜欢
  • 2020-07-30
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 2020-05-14
  • 2020-02-08
  • 2016-05-07
  • 1970-01-01
  • 2018-06-05
相关资源
最近更新 更多