Skip to content

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

Closed

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

Activity

  1. vszakats commented on May 16, 2026

    @vszakats
    Member

    Thanks for reporting. Does #21648 fix it for you?

  2. self-assigned this
    on May 16, 2026
  3. sfan5 commented on May 17, 2026

    @sfan5
    Author

    It does

    Testing pkg-config
    -I/tmp/prefix/usr/local/include -DCURL_STATICLIB
    
  4. added a commit that references this issue on May 17, 2026
    7bde6cb
  5. added a commit that references this issue on Jun 3, 2026
    4fc93d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions