conan-io / conan-io/examples

How to cross build md5 exsample for android?

Open
#93 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
126
Forks
65
PR merge metrics
No merged PRs in 30d

Description

After reading some documents ,I try cross-compile packages for Android platform: [Using toolchain from Android NDK](https://github.com/conan-io/docs/blob/develop/integrations/cross_platform/android.rst#using-toolchain-from-android-ndk)

I used my own /opt/toolchains/android-aarch64.cmake :

```
set(ANDROID_ABI arm64-v8a)
set(CMAKE_SIZEOF_VOID_P 8)

set(CMAKE_LIBRARY_ARCHITECTURE "aarch64-linux-android")
set(CMAKE_C_LIBRARY_ARCHITECTURE ${CMAKE_LIBRARY_ARCHITECTURE})
set(CMAKE_CXX_LIBRARY_ARCHITECTURE ${CMAKE_LIBRARY_ARCHITECTURE})

if(NOT DEFINED ANDROID_NDK)
set(ANDROID_NDK "$ENV{ANDROID_NDK_ROOT}")
endif()
if(NOT DEFINED ANDROID_NATIVE_API_LEVEL)
set(ANDROID_NATIVE_API_LEVEL $ENV{ANDROID_PLATFORM})
endif()
if(NOT DEFINED ANDROID_STL)
set(ANDROID_STL "c++_shared")
endif()
if(NOT DEFINED ANDROID_LD)
set(ANDROID_LD lld)
endif()

include(${ANDROID_NDK}/build/cmake/android.toolchain.cmake)
```
And wirte a conan profile local_android-ndk-arm64-v8a.txt :
```
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_static
compiler.version=11
os=Android
os.api_level=25
[build_requires]
[options]
[env]
CONAN_CMAKE_TOOLCHAIN_FILE=/opt/toolchains/android-aarch64.cmake
```
then
first `mkdir build && cd build `
second, `conan install --profile:host local_android-ndk-arm64-v8a.txt --build outdated --profile:build default .. `
the step it seems is successful ,as:
![image](https://user-images.githubusercontent.com/3354428/131110852-d86af626-cb29-48b8-8e4b-93fcb47f7ce6.png)

third: ` cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/opt/toolchains/android-aarch64.cmake`
```
this step have a error output:
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/packager/examples/libraries/poco/md5/build
CMake Error at build/conanbuildinfo.cmake:1369 (message):
Incorrect 'clang', is not the one detected by CMake: 'GNU'
Call Stack (most recent call first):
build/conanbuildinfo.cmake:930 (conan_check_compiler)
CMakeLists.txt:19 (conan_basic_setup)
```
Which step I did wrong?

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the example's CMakeLists.txt and the generated build/conanbuildinfo.cmake, then review the Android toolchain file and Conan host profile shown in the issue. Reproduce the cmake configuration command and trace why CMake detects GNU while Conan expects clang; done when the Android md5 example configures without the compiler mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, cmake, cpp
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.