CLION and Android NDK integration

I recently found CLion. I am trying to configure it to work with Android ndk:

  • I want it to use ndk sources and headers.

  • I want him to use the gcc and g ++ compiler in ndk.

  • I want it to use my make file, not cmake.

Failed to achieve these three goals, I hope you can help me :).

By the way, I use android ndk r10e if that matters.

+10
source share
2 answers

You can configure CLion to build on Android by following these steps:

  1. Install the standalone NDK toolkit ( https://developer.android.com/ndk/guides/standalone_toolchain.html )

  2. In the "Settings / Settings CLion" section of the "Assembly, Execution, Deployment> Tool Bundles" section, add a new tool chain for ARM, set the C compiler path to $ NDK_TOOLCHAIN_PATH / arm / bin / arm-linux-androideabi-clang, for the path the C ++ compiler, set the value to $ NDK_TOOLCHAIN_PATH / arm / bin / arm-linux-androideabi-clang ++, and if you're on Windows, set the MinGW path. The toolchain tab is a fairly new feature for Clion, so make sure you have the latest version of Clion installed.

  3. Repeat step 2 for any other architectures you want to support.

  4. Go to Create, Run, Deploy> CMake. Add a new profile for ARM. Install the toolkit for the ARM toolkit and set the CMake parameters to

-DCMAKE_CXX_FLAGS = "-fPIE -fPIC -lstd C ++"

-DCMAKE_AR = "$ NDK_TOOLCHAIN_PATH / shoulder / bin / link Linux-androideabi-ar"

-DCMAKE_RANLIB = "$ NDK_TOOLCHAIN_PATH / shoulder / bin / link Linux-androideabi-ranlib"

If you are using a Mac, you will need them too so that CMake does not use the isysroot option

-DCMAKE_OSX_SYSROOT = "/"

-DCMAKE_OSX_DEPLOYMENT_TARGET = ""

  1. Repeat step 4 for any other architectures that you want to support.

When building, install the profile on the architecture you need (instead of Debug / Release).

Ideally, you can specify the entire tool chain (ar, ranlib, etc.) Through CLion instead of using CMake options, but I have not yet found a way to do this.

+2
source

CLion can only work with CMake projects. Others at this stage are impossible. However, you can use Android Studio. It includes CLion-based C ++ support and works great with ndk.

-4
source

All Articles