pkg-config无法在sysroot目录下找到软件包 [英] pkg-config fails to find package under sysroot directory
问题描述
谁能告诉我为什么这可能会失败:
Can anyone please tell me why this might fail:
afeder@ubuntu:~/android/toolchain/sysroot$ ls $PKG_CONFIG_SYSROOT_DIR/usr/local/lib/pkgconfig/mozjs185.pc
/home/afeder/android/toolchain/sysroot/usr/local/lib/pkgconfig/mozjs185.pc
afeder@ubuntu:~/android/toolchain/sysroot$ pkg-config mozjs185 --cflags
Package mozjs185 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mozjs185.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mozjs185' found
根据man pkg-config(1)
,/usr/local/lib/pkgconfig
应该是默认的搜索路径之一.
According to man pkg-config(1)
, /usr/local/lib/pkgconfig
is supposed to be one of the default search paths.
推荐答案
我在这里找到了答案: http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html
I found the answer here: http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html
包装脚本不仅应设置
PKG_CONFIG_SYSROOT_DIR
变量:交叉编译时,您想忽略软件包 安装在系统中,而是仅依赖于安装在系统中的那些 交叉编译的环境.这可以通过重置来实现PKG_CONFIG_DIR
(列出其他搜索路径),并且在同一位置 时间设置PKG_CONFIG_LIBDIR
以覆盖默认的基本搜索 路径.
The wrapper script should not only set the
PKG_CONFIG_SYSROOT_DIR
variable: when cross-compiling you want to ignore the packages installed in the system, and instead rely only on those installed in the cross-compiled environment. This is achieved by resettingPKG_CONFIG_DIR
(which lists additional search paths), and at the same time settingPKG_CONFIG_LIBDIR
to override the default base search paths.
生成的CMake文件将如下所示:
The resulting CMake File would be something like this:
set(CMAKE_SYSROOT "/path/to/sysroot")
set(ENV{PKG_CONFIG_DIR} "")
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig")
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
免责声明:我使用了CMAKE_SYSROOT
变量,当您要将-sysroot
传递给g++
时,该变量很有用.如果您不希望这样做,则应使用其他名称来命名变量.
Disclaimer: I used the CMAKE_SYSROOT
variable which is useful when you want to pass -sysroot
to g++
. If you don't want this you should name your variable differently.
这篇关于pkg-config无法在sysroot目录下找到软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!