GammaRay icon indicating copy to clipboard operation
GammaRay copied to clipboard

Compiling for Android on Windows host

Open ptagl opened this issue 5 years ago • 8 comments

Hi,

I successfully compiled and ran GammaRay for Windows and was able to inspect a desktop application.

Now I would like to do the same for an Android application, but I was not able to build GammaRay. I tried with this command:

set ANDROID_NDK=C:/Tools/android/android-ndk-r18b cmake -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-android.cmake -DGAMMARAY_BUILD_UI=OFF -DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7 -DCMAKE_INSTALL_PREFIX=C:/Qt/5.12.1/android_armv7 ..

but it returns some errors:

CMake Warning (dev) at cmake/Toolchain-android.cmake:139 (set): implicitly converting 'path' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:140 (set): implicitly converting 'path' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:141 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:142 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:143 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:144 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:145 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:146 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Toolchain-android.cmake:147 (set): implicitly converting 'string' to 'STRING' type. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at cmake/Toolchain-android.cmake:157 (message): Couldn't find the Android NDK Root in C:/Tools/android/android-ndk-r18b/platforms/android-14/arch-arm Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeDetermineSystem.cmake:90 (include) CMakeLists.txt:69 (project)

CMake Error: CMake was unable to find a build program corresponding to "NMake Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

Am I doing something wrong?

Thanks for your help!

ptagl avatar Nov 08 '19 14:11 ptagl

not your fault. Things have changed since we wrote the cross-compile instructions for Android.

Try -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake where ANDROID_NDK=/path/to/android-ndk

Let me know if that works . I will change the instructions accordingly.

winterz avatar Nov 09 '19 14:11 winterz

make sure to clean your build directory first.

winterz avatar Nov 09 '19 14:11 winterz

Hi @winterz, thanks for your help!

I tried again with:

cmake -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DGAMMARAY_BUILD_UI=OFF -DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7 -DCMAKE_INSTALL_PREFIX=C:/Qt/5.12.1/android_armv7 ..

but it fails with this error message:

-- Performing Test HAVE_GXX_CXX11 -- Performing Test HAVE_GXX_CXX11 - Success CMake Error at CMakeLists.txt:382 (find_package): Could not find a package configuration file provided by "Qt5Core" (requested version 5.5) with any of the following names:

Qt5CoreConfig.cmake
qt5core-config.cmake

Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set "Qt5Core_DIR" to a directory containing one of the above files. If "Qt5Core" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred! See also "C:/Projects/KDAB/GammaRay/android-build/CMakeFiles/CMakeOutput.log". See also "C:/Projects/KDAB/GammaRay/android-build/CMakeFiles/CMakeError.log".

I also tried with different paths like:

-DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7/lib/cmake -DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7/lib/cmake/Qt5Core/

but had no luck.

Which path should I use to make it work?

ptagl avatar Nov 11 '19 12:11 ptagl

also make sure that the qmake from Qt5.12.1 is first in your %PATH% i.e. set "PATH=c:\Qt\5.12.1\android_armv7\bin;%PATH%" I also think -DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7/lib/cmake should work

winterz avatar Nov 11 '19 16:11 winterz

I tried integrating your suggestions, just to recap:

set ANDROID_NDK=C:/Tools/android/android-ndk-r18b set "PATH=c:/Qt/5.12.1/android_armv7/bin;%PATH%" cmake -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DGAMMARAY_BUILD_UI=OFF -DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/android_armv7/lib/cmake -DCMAKE_INSTALL_PREFIX=C:/Qt/5.12.1/android_armv7 ..

But I got the same error. I also tried adding

set Qt5Core_DIR=C:\Qt\5.12.1\android_armv7\lib\cmake\Qt5Core

as suggested in the error message but it didn't work.

Can it depend on Qt version? It seems like it's looking for the version 5.5...

ptagl avatar Nov 11 '19 16:11 ptagl

I updated the Install.txt instructions and tested.
update your checkout and try again following the new instructions.

winterz avatar Nov 26 '19 15:11 winterz

Hi @winterz, thanks a lot for your help.

I tried to use the updated instructions and ran these commands:

set ANDROID_NDK=C:/Tools/android/android-ndk-r18b C:/Tools/Android/android-ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe

I got an error related to clang for some reason:

-- ANDROID_PLATFORM not set. Defaulting to minimum supported version 16. -- Check for working CXX compiler: C:/Tools/Android/android-ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe CMake Error: Generator: execution of make failed. Make command was: nmake /nologo cmTC_8fcaf\fast && -- Check for working CXX compiler: C:/Tools/Android/android-ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- broken CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message): The C++ compiler

"C:/Tools/Android/android-ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Projects/KDAB/GammaRay/android-build/CMakeFiles/CMakeTmp

Run Build Command(s):nmake /nologo cmTC_8fcaf\fast && Impossibile trovare il file specificato
Generator: execution of make failed. Make command was: nmake /nologo cmTC_8fcaf\fast &&

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

-- Configuring incomplete, errors occurred! See also "C:/Projects/KDAB/GammaRay/android-build/CMakeFiles/CMakeOutput.log". See also "C:/Projects/KDAB/GammaRay/android-build/CMakeFiles/CMakeError.log".

ptagl avatar Dec 09 '19 16:12 ptagl

Might be a problem with Qt/NDK versions(s). Try to use Qt 5.12.6 with the latest NDK (r20). Also using QtCreator 4.11 to compile it should make your life easier.

bog-dan-ro avatar Dec 17 '19 07:12 bog-dan-ro