Thursday, September 3, 2015

libcec compilation for android (example)

1. get libplatform

1.1 run cmake in ./build

export ANDROID_NDK=~/dev/android/ndk && cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_toolchains/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/libplatform -DANDROID_ABI=armeabi-v7a -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 ..

1.2 make install

2. get libcec

2.1 run cmake in ./build

export ANDROID_NDK=~/dev/android/ndk && cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_toolchains/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/libcec -DANDROID_ABI=armeabi-v7a -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DCMAKE_PREFIX_PATH=/tmp/libplatform/lib/platform/ ..

2.2 make install

UPDATE (29/03/16) : add these two lines to CMakeLists.txt for 5.0> :



  1. Thanks for your example. Once obtained the file, how to use this library to execute a command standby?[Android project]

  2. if you take a look at the sources of the two examples in the libcec bundle (cec-client and cecc-client), you'll see how to get it to work. first make sure that you run one of the two binaries on the device to see if it works as expected. then depending on whether you want to call it from java or call it from a native binary, you'll either have to create a JNI wrapper for it or write a console app.

  3. Please, could you share how to use it in an Android app?