host zlib is found using a cross file.
See original GitHub issueDescribe the bug When using a cross file which is not setting pkg_config_libdir, meson find the host version of zlib with
MESON build-cross --cross-file=path_to/my-cross-file.txt
To Reproduce
Meson file:
project('hellomeson', 'c')
cc = meson.get_compiler('c')
libz_dep = dependency('zlib', required : false)
if not libz_dep.found()
warning('unable to find libz')
endif
executable('hello-meson', 'src/hello.c')
Cross file:
[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'arm64'
endian = 'little'
[properties]
c_args = []
cpp_args = []
objc_args = []
objcpp_args = []
c_link_args = []
cpp_link_args = []
objc_link_args = []
objcpp_link_args = []
pkg_config_libdir = ['__unknown_sysroot__']
[binaries]
c = ['aarch64-linux-gnu-gcc']
cpp = ['aarch64-linux-gnu-g++']
ar = ['aarch64-linux-gnu-ar']
pkgconfig = 'pkg-config'
strip = ['aarch64-linux-gnu-strip']
Expected behavior To not find any zlib or at least not the one from my host and then use it…
system parameters
- Is this a cross build or just a plain native build (for the same computer)? cross build
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) Ubuntu 18.04
- what Python version are you using e.g. 3.8.0 3.6.9
- what
meson --version
master - what
ninja --version
if it’s a Ninja build 1.8.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:33 (27 by maintainers)
Top Results From Across the Web
zlib header not found when cross compiling with mingw?
When I just run ./configure it compiles fine. I'm trying to cross-compile a 64 bit executable for Windows on Debian 7 with MinGW-64....
Read more >use-pkg-config-to-locate-zlib.patch\gnutls\gnutls\recipes ...
If zlib support is enabled, then failure to find zlib via pkg-config is now treated as a fatal error. Change based on ChromeOS...
Read more >zlib.h is missing from cross compile toolchain - NXP Community
I build the toolchain by : bitbake meta-toolchain # ... But when I compile an application which includes "zlib.h", it complains "include file...
Read more >Build a simple CMake project using Conan
The easiest way to install the Zlib library and find it from our project with Conan is using a conanfile.txt file. Let's create...
Read more >gdb-9.2/zlib/configure - toolchain/gdb - Git at Google
$as_echo "$0: the shells that I found on your system." ... --with-cross-host=HOST configuring with a cross compiler. --with-system-zlib use installed libz.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Should be fixed with #8096.
I opted for reverting to the old behavior since I couldn’t find a solution based on CMake variables that should do the correct thing in all circumstances.
Sorry, but this is wrong. CMake is a valid dependency backend in meson (just like
pkg-config
) and also capable of finding cross dependencies. However, it is sadly not correctly setup out of the box currently, resulting in this error.Using the setup in https://github.com/mesonbuild/meson/issues/8028#issuecomment-734360181 to set the CMake variables (wich should cause CMake to behave correctly) should work for now if disabling CMake in the cross file doesn’t work for some reason.
Also, to clarify, I agree that this is a valid issue and the current behavior should be fixed, I only disagree with using a cross CMake binary. The solution I would prefer is to set these variables automatically for the cross-case for the next point release, which should also fix the issue.