6

I am trying to build an Android project using the android NDK.

I have added the NDK to the QT Versions, the build kit was auto detected but when running CMake I get the following error:

Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-g++", "-DCMAKE_C_COMPILER:STRING=/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc", "-DCMAKE_PREFIX_PATH:STRING=/home/self/Qt5.9.6/5.9.6/android_x86", "-DQT_QMAKE_EXECUTABLE:STRING=/home/self/Qt5.9.6/5.9.6/android_x86/bin/qmake".
The C compiler identification is GNU 4.9.0
The CXX compiler identification is GNU 4.9.0
Check for working C compiler: /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
Check for working C compiler: /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/ninja" "cmTC_991f8"
    [1/2] Building C object CMakeFiles/cmTC_991f8.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_991f8
    FAILED: cmTC_991f8 
    : && /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc   -rdynamic CMakeFiles/cmTC_991f8.dir/testCCompiler.c.o  -o cmTC_991f8   && :
    /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
    /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot open crtend_android.o: No such file or directory
    /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -lc
    /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -ldl
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


Configuring incomplete, errors occurred!
See also "/tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeOutput.log".
See also "/tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeError.log".
CMake Project parsing failed.

What am I doing wrong?

EDIT So as suggested I downloaded NDK 10e ... Problem seems to stay the same:

/usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52: error: The C compiler "/home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc" is not able to compile a simple test program.
 It fails with the following output: Change Dir: /tmp/QtCreator-vkcYcW/qtc-cmake-XXyT08En/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/ninja" "cmTC_3ab69" 
[1/2] Building C object CMakeFiles/cmTC_3ab69.dir/testCCompiler.c.o 
[2/2] Linking C executable cmTC_3ab69 FAILED: cmTC_3ab69 : && /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc   -rdynamic CMakeFiles/cmTC_3ab69.dir/testCCompiler.c.o  -o cmTC_3ab69   && : 
/home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-androi.d/4.9/../../../../i686-linux-android/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot open crtend_android.o: No such file or directory /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -lc /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -ldl 
collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
Alex
  • 32,506
  • 16
  • 106
  • 171
  • What version of NDK do you have? – eyllanesc Jul 11 '18 at 08:19
  • @eyllanesc the latest one downloaded yesterday. R17b – Alex Jul 11 '18 at 08:28
  • Qt does not support the latest version of NDK, you must use version 10e, check the docs: http://doc.qt.io/qt-5/androidgs.html – eyllanesc Jul 11 '18 at 08:29
  • @eyllanesc interesting. But they recommend 10e, not require. Is this sure the cause? – Alex Jul 11 '18 at 08:32
  • @eyllanesc alright. So post it as an answer please :) – Alex Jul 11 '18 at 08:34
  • Yes, it has already happened to me, and I resolved using that version. I use qmake, not cmake, but I think that in both cases it should work. – eyllanesc Jul 11 '18 at 08:34
  • Isn't this similar [“The C Compiler is not able to compile a simple test program” using CMake and Android NDK](https://stackoverflow.com/questions/41346745/the-c-compiler-is-not-able-to-compile-a-simple-test-program-using-cmake) – Mohammad Kanan Jul 16 '18 at 19:16

1 Answers1

1

Qt does not support a recent version of NDK, in the docs it is recommended to use NDK 10e

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • @Alex Why not use qmake through Qtcreator ?, then adapt it to cmake – eyllanesc Jul 12 '18 at 17:07
  • @Alex What I point out is that first you make sure you have the right packages so we can discard some possible causes. – eyllanesc Jul 12 '18 at 17:20
  • How can I build the existing project (https://github.com/mapsme/omim) using QMake? – Alex Jul 12 '18 at 17:34
  • mmm, so you want to compile the project, let me see if I can compile it and I tell you my progress. – eyllanesc Jul 12 '18 at 17:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/174903/discussion-between-alex-and-eyllanesc). – Alex Jul 12 '18 at 17:36