pkg-config 在 sysroot 目录下找不到包
谁能告诉我为什么这可能会失败:
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
应该是默认搜索路径之一。
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
According to man pkg-config(1)
, /usr/local/lib/pkgconfig
is supposed to be one of the default search paths.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里找到了答案: http://www.flameeyes.eu/autotools -mythbuster/pkgconfig/cross-compiling.html
生成的 CMake 文件将如下所示:
免责声明:我使用了
CMAKE_SYSROOT
变量,当您想要将-sysroot
传递给g++
时,该变量非常有用。如果您不希望这样,您应该以不同的方式命名您的变量。I found the answer here: http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html
The resulting CMake File would be something like this:
Disclaimer: I used the
CMAKE_SYSROOT
variable which is useful when you want to pass-sysroot
tog++
. If you don't want this you should name your variable differently.如果您使用交叉编译器,则需要 1) 安装适当的 pkg-config 包装器,2) 设置包装器要选取的适当环境变量。您可以使用 apt-cache search pkg-config- 找到合适的包装器,然后为目标系统安装合适的包装器。例如,如果交叉编译到armhf:
sudo apt-get install pkg-config-arm-linux-gnueabihf
。然后,在调用包装器之前根据需要设置环境变量PKG_CONFIG_DIR
、PKG_CONFIG_LIBDIR
和PKG_CONFIG_SYSROOT_DIR
。如果您使用 CMake 进行交叉编译,请注意 CMake 的
pkg_search_module
命令(由FindPkgConfig.cmake
提供)似乎无法正确设置包装器的环境。相反,您应该使用 PKG_CONFIG_PATH 环境变量。另请参阅在 cmake 中设置 PKG_CONFIG_PATH
If you're using a cross-compiler, then you need to 1) install the appropriate pkg-config wrapper and 2) set the appropriate environment variables to be picked up by the wrapper. You can find the appropriate wrapper with
apt-cache search pkg-config-
and then install the appropriate one for the target system. E.g. if cross-compiling to armhf:sudo apt-get install pkg-config-arm-linux-gnueabihf
. Then, set environment variablesPKG_CONFIG_DIR
,PKG_CONFIG_LIBDIR
, andPKG_CONFIG_SYSROOT_DIR
as required before invoking the wrapper.If you're cross compiling using CMake, note that CMake's
pkg_search_module
command (provided byFindPkgConfig.cmake
) doesn't appear to correctly set the environment for the wrapper. Rather, you should use the PKG_CONFIG_PATH environment variable.See also set PKG_CONFIG_PATH in cmake