Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Monday, November 25, 2013

Getting Android CMake to work....

I recently wanted to get one of my libraries - FTL to build and run on my nexus 7 tablet. Since everything is done via CMake, the obvious question was could I just get the Android NDK toolchain setup and building without any changes to my library? (For those looking to setup it up manually without CMake see this post)

First step.... getting Android CMake to work

There are a number of things spread around the net but nothing conclusive to point out obvious noobie mistakes I came across.... so I documented my findings just in case someone else has the same issues:

1. After setting up the NDK r9 x64 version as:

export NDK=~/Dev/android-ndk-r9
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=$HOME/Dev/Install/android-toolchain --toolchain=arm-linux-androideabi-4.8
 
It is very important to put the whole path in and not the './' instead. Otherwise it will complain about the NDK install not being found. The toolchain should match your device. [From Android CMake docs]

2. Next you need Android CMake. The project on Google Code is no longer supported, but the OpenCV version appears to be the latest version, so grab it from here. You just need the .cmake file, so I grabbed the Google Code version and replaced the android.toolchain.cmake file with the latest version. I placed this at ~/Dev/Install/android-cmake.

3. Test it on the Android CMake samples available on the Google Code repository. Setup the environment:

export ANDROID_NDK=~/Dev/android-ndk-r9
export ANDROID_NDK_STANDALONE_TOOLCHAIN=~/Dev/Install/android-toolchain

export ANDROID_NDK_TOOLCHAINS_PATH=$ANDROID_NDK
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8

export PATH=$ANDROID_NDK_STANDALONE_TOOLCHAIN/bin:$PATH
export ANDROID_CMAKE=~/Dev/Install/android-cmake
export ANDTOOLCHAIN=$ANDROID_CMAKE/toolchain/android.toolchain.cmake

alias android-cmake='ccmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DANDROID_NDK=$ANDROID_NDK -DCMAKE_C_COMPILER=arm-linux-androideabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-androideabi-g++ -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 -DANDROID_NDK_TOOLCHAINS_PATH=~/Dev/android-ndk-r9'

The last 'alias' command should be on one line or break it up slashes. The tricky bit is the distinction between the ANDROID_NDK and the ANDROID_NDK_STANDALONE_TOOLCHAIN. The latter is good for directly accessing the compilers etc. and the former is needed by Android CMake to find the NDK. If not set correctly, you get the "Could not find any working toolchain in the NDK. Probably your Android NDK is broken" message.

If all goes well then doing the following will work:

mkdir build
cd build
android-cmake ..
make -j 4

At 'android-cmake' line, I used the Curses front-end for CMake. Replace it with your preferred front-end. The rest of the documentation for Hello-CMake example should work fine. More on Android CMake porting of libraries later....

Cheers Shakes - L3mming

Thursday, December 3, 2009

Best Poster Award - DICTA 2009

Well the DICTA conference, which is "the main Australian conference on digital image processing, machine vision and related areas." is finally over. I presented my work, which is encompassed in my FTL library, as a poster.

The response to the work was overwhelming, and the end result was the Best Poster Award at the conference. Special thanks to my supervisor Imants Svalbe and Steve Morton for print and processing. I have added the poster to the FTL repository (so its logged). You can view it here.

A lot of interest was shown in the code of the work also, including from Canon Information Systems Research Australia (CISRA) personnel, hopefully it will increase its usage.

Cheers
Shakes - L3mming

Saturday, August 15, 2009

NTTW - The Number Theoretic Transform Library

I have just released my Number Theoretic Transforms (NTT) C library under GPL v3. I've called it NTTW to match FFTW, a well known Discrete Fourier Transform library. It's functions compute the NTTs using Cooley-Tukey's Fast algorithm. The current release only has dyadic length functions. Prime length functions will be released after I submit a journal paper I've been working on.

NTTW is to be part of a larger library called Finite Transform Library (FTL). You can call it Faster Than Light too. :P This new library will feature other transforms I've been working on in my Ph.D, as well as incorporating FFTW. More news later as I complete papers and libraries.

Cheers
Shakes - L3mming