libffi 由 pkg-config 安装和识别,但不是由 glib

libffi installed and recogonized by pkg-config, but not by glib

我想为 Windows 交叉编译 glib。配置抛出此错误:

configure: WARNING: using cross tools not prefixed with host triplet configure: error: Package requirements (libffi >= 3.0.0) were not met:

No package 'libffi' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBFFI_CFLAGS and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.

然而 pkg-config --modversion libffi 打印“3.1”。我已经从 debian jessie 存储库安装了 libffi 和 libffi-dev。

(我不确定这是否属于超级用户,因为它也与包问题有关)

Checkout the steps to Bootstrap GLIB with MinGW


1。基本上需要先 下载源代码,构建并安装 libffi

cd /path/to/libffi/source
mkdir bld
cd bld
../configure --prefix=/mingw
make && make install

2。 ...随后 构建 glib 没有 PKG_CONFIG

cd /path/to/glib/source
mkdir bld
cd bld
export LIBFFI_CFLAGS='-I /mingw/lib/libffi-VERSION/include'
    VERSION is to be replaced with whatever version you built above.
    For me VERSION is 3.0.10.
export LIBFFI_LIBS=-lffi
export lt_cv_deplibs_check_method="pass_all"
export CFLAGS=”O0 -g -pipe -Wall -march=i486 -mms-bitfields -mthreads”
export CPPFLAGS=”-DG_ATOMIC_OP_USE_GCC_BUILTINS=1”
export LDFLAGS=”-Wl,--enable-auto-image-base”
../configure --prefix=/mingw --with-pcre=internal --disable-static --disable-gtk-doc --enable-silent-rules
make
make install

3。随后,可以构建和安装pkg_config

4。然后glib可以正常重建如下:

cd /path/to/glib/source/bld
make clean
../configure --prefix=/mingw
make
make install

就我而言,当 运行ning npm i 时,我收到了下一条错误消息:

node-gyp rebuild

Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'gobject-2.0', not found
gyp: Call to 'pkg-config --cflags  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

我发现问题出在导出 PATH

所以我运行brew reinstall -s poppler

在安装结束时,您可以运行导出路径

If you need to have qt first in your PATH run:
  echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

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

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

这为我修复了它。

希望对您有所帮助。