Compiling and Running a FastCV™ Sample App

Create the Android APK & Compiling Shared object

We will now compile and build the Android application APK using the Eclipse IDE environment. The sample applications have several Java classes to create the provide GUI functionality, read the camera frame, allow user interaction, and provide performance data to the user

Building the FastCVSample application

Create a new project in Eclipse by selecting File->New->Project.... Choose Android->Android Project from the Wizard selection.

Select 'Create project from existing source' and browse to the <DEVELOPMENT_ROOT>\fastcv-android-xx-yy-zz\ directory.

Click Finish.

Eclipse New Android Project
Eclipse "New Android Project" panel

Adjust the project name and click Finish

To compile the native part, we'll need to add C/C++ attributes to the project.

To do so, use clock on File > New > Other > C/C++ > Convert to a C++ Project menu option to add C/C++ attributes to the project.

Contrary to what the text of the menu option implies, this does not replace the Android application attributes with C/C++ application attributes, nor does it create a new project in place of, or side-by-side with, your Android application. It only adds additional attributes for C/C++ to the project, alongside the Android attributes.

The wizard invoked to add C/C++ attributes for your project will ask you to configure the project type and toolchains to use for the project. By selecting Makefile project for the project type, and Other Toolchain for the toolchains, you configure the project to invoke GNU Make to build the C/C++ portion of your project.

This is where you will be integrating the two build systems (the Java part using the ADT, with the C/C++ part using the NDK).

The makefile you will create will invoke the ndk-build script from the NDK to take care of building the native shared object for your application, and then the ADT will automatically include that shared object when it constructs your application package.


The standard installation of Eclipse has automatic compilation turned on. The very first time you compile the app, you may receive some error messages from Eclipse. Project->Clean...->Clean All Projects should fix these errors as Eclipse has to build some standard directories. This also creates the APK package for deployment.

Copy lib/libfastcv.a to your ndk lib directory (e.g <Android-NDK-Root/platforms/<Android API>/arch-arm/usr/lib)

Create a directory under the ndk include directory called fastcv. Copy the contents of inc directory from the installation directory to the new directory you just created under the ndk include directory (e.g <Android-NDK-Root/platforms/<Android API>/arch-arm/usr/include/fastcv)

Now when you click on "Build All", you should see something like follows in the Console Log:

**** Build of configuration Default for project FastCVSample ****

make all
Host OS was auto-detected: windows
make[1]: Entering directory `/cygdrive/c/Development/fastcv-android-xx-yy-zz'
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : fastcvsample <= fastcvsample.cpp
Compile++ thumb  : fastcvsample <= FPSCounter.cpp
Compile++ thumb  : fastcvsample <= CameraRendererRGB565GL2.cpp
Compile++ thumb  : fastcvsample <= CameraUtil.cpp
StaticLibrary  : libstdc++.a
SharedLibrary  :
Install        : => libs/armeabi/
make[1]: Leaving directory `/cygdrive/c/Development/fastcv-android-xx-yy-zz'

The apk should be inside the \bin\ directory. The app has been successfully built.

Run the Sample Application

To install on your device, run the following from bin directory:

Adb install <project name>.apk

This should install the sample app on the device, and you should be able to run the app from the device.