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.
I found the answer here: http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html
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.
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})
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With