Skip to content

Android: pkg-config file references zlib, which does not exist #21647

@sfan5

Description

@sfan5

I did this

Cross-compile libcurl for Android and expect another library to correctly pick it up using pkg-config.

Full test script:

#!/bin/bash
[ -z "$ANDROID_NDK" ] && exit 1
toolchain=$(echo "$ANDROID_NDK"/toolchains/llvm/prebuilt/*)
export PATH="$toolchain/bin:$ANDROID_NDK:$PATH"

export CC=aarch64-linux-android21-clang
export CXX=aarch64-linux-android21-clang++
export AR=llvm-ar
export RANLIB=llvm-ranlib

rm -rf prefix && mkdir prefix
export PKG_CONFIG_SYSROOT_DIR="$PWD/prefix"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/usr/local/lib/pkgconfig"

rm -rf build && mkdir build
cd build

../curl-8.20.0/configure \
	--host=aarch64-linux-android21 --without-ssl --without-libpsl \
	--disable-shared --enable-static --disable-{debug,docs}

make -j4
make DESTDIR="$PKG_CONFIG_SYSROOT_DIR" install

echo "Testing pkg-config"
pkg-config --cflags libcurl

I expected the following

At the end of the script libcurl can be correctly found by pkg-config.

What happens instead:

Testing pkg-config
Package zlib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zlib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zlib', required by 'libcurl', not found

Looking at prefix/usr/local/lib/pkgconfig/libcurl.pc we see:

[...]
Requires: zlib
Requires.private: zlib
[...]

However Android does not use pkg-config at all, so requiring zlib here breaks it.

Cross-checking with config.log shows that zlib was found "standalone" and not via pkg-config:

configure:24287: checking for pkg-config
configure:24311: found /usr/bin/pkg-config
configure:24323: result: /usr/bin/pkg-config
configure:24348: checking for zlib options with pkg-config
configure:24364: result: no
configure:24484: checking for inflateEnd in -lz
configure:24506: aarch64-linux-android21-clang -o conftest -Qunused-arguments -Werror-implicit-function-declaration -O2  -D_GNU_SOURCE  conftest.c -lz   >&5
configure:24506: $? = 0
configure:24516: result: yes
configure:24540: checking for zlib.h
configure:24540: aarch64-linux-android21-clang -c -Qunused-arguments -Werror-implicit-function-declaration -O2  -D_GNU_SOURCE conftest.c >&5
configure:24540: $? = 0
configure:24540: result: yes
configure:24628: found both libz and libz.h header

curl/libcurl version

8.20.0

operating system

host: Arch Linux x86_64
target: Android API 21 ABI arm64-v8a

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions