I am trying to build libzmq for Android using CMake and the toolchain embedded in the NDK.

My system is MacOS 10.14.3

I freshly downloaded the latest NDK [r20] but the problem was here already with r19c.

The CMake process fails when it tries to compile a "simple test program" and says:

ld: unknown option: --sysroot=/Users/me/android-ndk-r20/platforms/android-28/arch-arm

I tried to compile another library (custom) to confirm that its a toolchain issue and got the same error.

In the --helpoutput of the compiler (from the embedded toolchain), I found this:

-isysroot <dir>         Set the system root directory (usually /)

Could there be an issue with the NDK toolchain for MacOS that passes the --sysroot parameter instead of the -isysroot one?
Is there a workaround? (Like something to add in the CMake toolchain file maybe?)

Here is my CMake toolchain file :

set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
set(CMAKE_ANDROID_NDK /Users/me/android-ndk-r20)
set(CMAKE_ANDROID_STL_TYPE c++_static)

In the meantime, I will run this through a Ubuntu docker image and see how it goes.

2 Answers 2


I ran into this same exact issue on OSX and ended up reverting to the NDK 18b revision and it worked for my needs.

Same problem on the NDK Rev 19c. I think there's an issue with the NDK on r19c and r20

  • Thanks for the input. I ended up using a docker Ubuntu and cross-compiling using the CMake toolchain file from the Android NDK. This way, I still use the latest NDK. I didn't post an answer because it does not really answer the question :S
    – PlikPlok
    Commented Jun 19, 2019 at 15:36

Toolchain needs to be specified:


The Android Gradle Plugin invokes CMake with this argument which leads to no error. See NDK's CMake page

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .