Qt creator has issues while building android for x86 using Cmake



  • Hello,

    I tried to build a simple app from http://doc.qt.io/qtcreator/qtcreator-accelbubble-example.html to build on my Linux virtual machine. The program compiles perfect with the desktop build but has an issue when building for android.
    The error i get is as follows:

    -- Check for working CXX compiler: /home/user/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
    -- Check for working CXX compiler: /home/user/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -- broken
    CMake Error at /home/user/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeTestCXXCompiler.cmake:54 (message):
      The C++ compiler
      "/home/user/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
      is not able to compile a simple test program.
    
      It fails with the following output:
    
       Change Dir: /home/user/testProjects/build-bubbleWork-Android_for_x86_GCC_4_9_Qt_5_9_3_for_Android_x86-newBuild/CMakeFiles/CMakeTmp
    

    I have installed all the necessary tools from android studio and linked my android SDK and NDK (SDK Version: 26.1.1, NDK Version: 16.1.4479499) to my Qt creator.

    The java settings: java-1.8.0-openjdk-amd64

    the issue I feel is the default android GCC compilers.

    The compiler i am currently using for C and CXX is: toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
    I did use different compilers but all gave me the same error.

    What can be the issue for this? Should I use Clang instead of GCC? Do I need to create a platform-independent build tool?


  • Moderators

    @ankitdg In the title you write you're building for x86, but you're using compiler for ARM.
    Also, you should check the CMake log to see what exactly fails.



  • Hello,

    Sorry for the novice mistake! I was trying to use different compilers in the NDK but i end up with the same error. The code i uploaded before was from one of my trials.
    I did change my configuration to x86 but i still get the same error. Since this is my 1st time for android, I may have missed something.

    The error stays the same. The 1st few line of my cmake error log states:

    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: /home/user/android-ndk-r16b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-g++ 
    Build flags: 
    Id flags: 
    The output was:
    1
    /home/user/android-ndk-r16b/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/user/android-ndk-r16b/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/user/android-ndk-r16b/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 -lstdc++
    /home/user/android-ndk-r16b/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 -lm
    /home/user/android-ndk-r16b/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/user/android-ndk-r16b/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
    
    

    and the cmake output states

    -- The CXX compiler identification is GNU 4.9.0
    -- Check for working CXX compiler: /home/user/android-ndk-r16b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
    -- Check for working CXX compiler: /home/user/android-ndk-r16b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc -- broken
    CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
      The C++ compiler
      "/home/user/android-ndk-r16b/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: /home/user/testProjects/build-bubbleWork-Android_for_x86_GCC_4_9_Qt_5_9_3_for_Android_x86-Default/CMakeFiles/CMakeTmp
    
      
    
      Run Build Command:"/usr/bin/make" "cmTC_c05c5/fast"
    
      /usr/bin/make -f CMakeFiles/cmTC_c05c5.dir/build.make
      CMakeFiles/cmTC_c05c5.dir/build
    
      make[1]: Entering directory
      '/home/user/testProjects/build-bubbleWork-Android_for_x86_GCC_4_9_Qt_5_9_3_for_Android_x86-Default/CMakeFiles/CMakeTmp'
    
    
      Building CXX object CMakeFiles/cmTC_c05c5.dir/testCXXCompiler.cxx.o
    
      
      /home/user/android-ndk-r16b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
      -o CMakeFiles/cmTC_c05c5.dir/testCXXCompiler.cxx.o -c
      /home/user/testProjects/build-bubbleWork-Android_for_x86_GCC_4_9_Qt_5_9_3_for_Android_x86-Default/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    
    
      Linking CXX executable cmTC_c05c5
    
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c05c5.dir/link.txt
      --verbose=1
    
      
      /home/user/android-ndk-r16b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
      CMakeFiles/cmTC_c05c5.dir/testCXXCompiler.cxx.o -o cmTC_c05c5 -rdynamic
    
      
      /home/user/android-ndk-r16b/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
    
    


Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.