Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Unable to build for Android with both QMake and CMake

    Mobile and Embedded
    android cmake
    1
    2
    2072
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      David Demelier last edited by David Demelier

      Hello

      I'm trying to build an application for Android using Qt 5.10, I've followed the articles on:

      http://doc.qt.io/qt-5/android-support.html
      http://wiki.qt.io/Android

      Builts were fine and installed, I've used the following invocations:

      (for amd64)

      ~/qt/configure -xplatform android-g++ --disable-rpath -nomake tests -nomake examples -android-ndk ~/.local/share/ndk-bundle -android-sdk ~/.local/share -android-ndk-host linux-x86_64 -android-toolchain-version 4.9 -skip qttranslations -skip qtserialport -no-warnings-are-errors -prefix ~/.local/lib/qt/x86_64 -android-arch x86_64 -android-ndk-platform android-24 -opensource -confirm-license
      

      (for arm)

      ~/qt/configure -xplatform android-g++ --disable-rpath -nomake tests -nomake examples -android-ndk ~/.local/share/ndk-bundle -android-sdk ~/.local/share -android-ndk-host linux-x86_64 -android-toolchain-version 4.9 -skip qttranslations -skip qtserialport -no-warnings-are-errors -prefix ~/.local/lib/qt/arm -android-arch armeabi-v7a -android-ndk-platform android-24 -opensource -confirm-license
      

      And installed NDK + SDK tools under the following tree:

      • ~/.local/share
        • ndk-bundle
        • platforms
          • android-24
        • system-images
          • android-24
        • emulator
        • android (the tools extracted here)
        • tools (the additional tools)

      I've setup the kits like this:

      alt text

      Using CMake, I get the following error:

          "/home/markand/.local/share/ndk-bundle/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: /tmp/QtCreator-kKSAbZ/qtc-cmake-XXyhI3dl/CMakeFiles/CMakeTmp
          
          Run Build Command:"/usr/bin/ninja-build" "cmTC_95308"
          [1/2] Building CXX object CMakeFiles/cmTC_95308.dir/testCXXCompiler.cxx.o
          [2/2] Linking CXX executable cmTC_95308
          FAILED: cmTC_95308 
          : && /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ --sysroot=/home/markand/.local/share/ndk-bundle/sysroot    -rdynamic CMakeFiles/cmTC_95308.dir/testCXXCompiler.cxx.o  -o cmTC_95308   && :
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_android.o: No such file or directory
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lstdc++
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lm
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc
          /home/markand/.local/share/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
          collect2: error: ld returned 1 exit status
          ninja: build stopped: subcommand failed.
      

      Using QMake I get the following error:

      10:10:47: Starting: "/usr/bin/make" 
      /home/markand/.local/share/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-g++ -c -D__ANDROID_API__=16 --sysroot=/home/markand/.local/share/ndk-bundle/sysroot -isystem /home/markand/.local/share/ndk-bundle/sysroot/usr/include/x86_64-linux-android -isystem /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include -fstack-protector-strong -DANDROID -g -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../Test -I. -I../../.local/lib/qt/x86_64/include -I../../.local/lib/qt/x86_64/include/QtQuick -I../../.local/lib/qt/x86_64/include/QtGui -I../../.local/lib/qt/x86_64/include/QtQml -I../../.local/lib/qt/x86_64/include/QtNetwork -I../../.local/lib/qt/x86_64/include/QtCore -I. -I../../.local/lib/qt/x86_64/mkspecs/android-g++ -o main.o ../Test/main.cpp
      In file included from /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/random:38:0,
                       from /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_algo.h:66,
                       from /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm:62,
                       from ../../.local/lib/qt/x86_64/include/QtCore/qglobal.h:110,
                       from ../../.local/lib/qt/x86_64/include/QtGui/qtguiglobal.h:43,
                       from ../../.local/lib/qt/x86_64/include/QtGui/qguiapplication.h:43,
                       from ../../.local/lib/qt/x86_64/include/QtGui/QGuiApplication:1,
                       from ../Test/main.cpp:1:
      /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cmath:1118:11: error: '::log2' has not been declared
         using ::log2;
                 ^
      /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cmath:1119:11: error: '::log2f' has not been declared
         using ::log2f;
                 ^
      /home/markand/.local/share/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/cmath:1120:11: error: '::log2l' has not been declared
         using ::log2l;
      

      What do I miss or doing wrong?

      1 Reply Last reply Reply Quote 0
      • D
        David Demelier last edited by

        Okay, I've just seen in the Building for android page that at most NDK r10 must be used. I recompiled qt with it and targeting android-21 platform. It works with QMake but with CMake I still get the same error though. Quite a step ahead fortunately :)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post