Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Simple android build fails link on Qt 5.12.4 arm64-v8a "cannot find -lc++



  • I"m trying to move our android application from 5.11 to 5.12. In doing so I upgrade the NDK to r20. But whenever I use r20 I get the following link error: cannot find -lc++

    I can reproduce this using a simple Qt Quick template application as well which includes nothing but a Window. Not sure if it is somehow using the wrong toolchain or what. I hacked the makefile to add a -v to the link. Here is the output from that.

    11:53:07: Running steps for project TestAndroid...
    11:53:07: Configuration unchanged, skipping qmake step.
    11:53:07: Starting: "/Users/Don/android-ndk-r20/prebuilt/darwin-x86_64/bin/make" -j16
    /Users/Don/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -v -D__ANDROID_API__=21 -target aarch64-none-linux-android -gcc-toolchain /Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot=/Users/Don/android-ndk-r20/platforms/android-21/arch-arm64/ -Wl,-soname,libTestAndroid.so -Wl,-rpath=/Users/Don/Qt/5.12.4/android_arm64_v8a/lib -Wl,--no-undefined -Wl,-z,noexecstack -shared -o libTestAndroid.so main.o qrc_qml.o   /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Quick.so -L/opt/android/android-ndk-r19c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Gui.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Qml.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Network.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Core.so -lGLESv2  -L/Users/Don/android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/arm64-v8a /Users/Don/android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++.so.21 -llog -lz -lm -ldl -lc
    Android (5220042 based on r346389c) clang version 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf643d27dbca1bb228957008617) (https://android.googlesource.com/toolchain/llvm 3c393fe7a7e13b0fba4ac75a01aa683d7a5b11cd) (based on LLVM 8.0.7svn)
    Target: aarch64-none-linux-android
    Thread model: posix
    InstalledDir: /Users/Don/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin
    Found candidate GCC installation: /Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x
    Selected GCC installation: /Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x
    Candidate multilib: .;@m64
    Selected multilib: .;@m64
     "/Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld" --sysroot=/Users/Don/android-ndk-r20/platforms/android-21/arch-arm64/ -EL --fix-cortex-a53-843419 -z now -z relro --hash-style=both --enable-new-dtags --eh-frame-hdr -m aarch64linux -shared -o libTestAndroid.so /Users/Don/android-ndk-r20/platforms/android-21/arch-arm64//usr/lib/crtbegin_so.o -L/opt/android/android-ndk-r19c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -L/Users/Don/android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -L/Users/Don/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/8.0.7/lib/linux/aarch64 -L/Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x -L/Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib/../lib64 -L/Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib -L/Users/Don/android-ndk-r20/platforms/android-21/arch-arm64//usr/lib --exclude-libs libgcc.a --exclude-libs libatomic.a -soname libTestAndroid.so -rpath=/Users/Don/Qt/5.12.4/android_arm64_v8a/lib --no-undefined -z noexecstack main.o qrc_qml.o /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Quick.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Gui.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Qml.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Network.so /Users/Don/Qt/5.12.4/android_arm64_v8a/lib/libQt5Core.so -lGLESv2 /Users/Don/android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++.so.21 -llog -lz -lm -ldl -lc -lc++ -lm -lgcc -ldl -lc -lgcc -ldl /Users/Don/android-ndk-r20/platforms/android-21/arch-arm64//usr/lib/crtend_so.o
    /Users/Don/android-ndk-r20/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lc++
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [libTestAndroid.so] Error 1
    11:53:07: The process "/Users/Don/android-ndk-r20/prebuilt/darwin-x86_64/bin/make" exited with code 2.
    Error while building/deploying project TestAndroid (kit: Android for arm64-v8a (Clang Qt 5.12.4 for Android ARM64-v8a))
    When executing step "Make"
    11:53:07: Elapsed time: 00:00.
    

    I'm assuming I have some sort of NDK/SDK or something set up incorrectly but I can figure out what. If I change back to 5.11 and r16 NDK it all works fine.



  • Try r18 or r19.
    I'm on r18 without issues on 5.12... except when building as a 64bit Android app, it crashes... but works fine as a 32bit app...


  • Lifetime Qt Champion

    Hi @donlakeflyer,

    please see this thread.

    Regards



  • Thanks so much everyone. I'll give this a try. Sorry I didn't do a search in forums before I entered this.


Log in to reply