Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Clang instead of GCC with Android studio 2.2's CMake support

We're trying to make use of the new CMake support in Android Studio's 2.2 gradle.

By default, the toolchain is set to use GCC and it seems to be broken, so compilation fails miserably.

How can I tell it to work with clang?

I tried to use -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.5 in the Arguments parameter within the scope of CMake in our build.gradle, but that also fails (it was documented in the comments of android.toolchain.cmake that came with the NDK claiming that such toolchain doesn't exist.

like image 688
Max Raskin Avatar asked Jun 28 '16 07:06

Max Raskin


1 Answers

Google seem to have updated their documentation on that, adding a new -DANDROID_TOOLCHAIN=clang argument, see -

http://tools.android.com/tech-docs/external-c-builds

UPDATE Latest Android Studio builds as of today (Aug 21, 2016) have a checkbox when starting a new project, to enable C++ Support, I tested it on Windows and it works.

Cheers

like image 198
Max Raskin Avatar answered Nov 19 '22 23:11

Max Raskin