My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
HowToCompileTheNativeSources  
How to compile the native sources
Updated May 23, 2010 by tdomhan

Introduction

The AndAR project contains some native C sources. This page describes how to compile those.

Details

Since NDK r4

  1. Install the android NDK
  2. (windows only) Install Cygwin
  3. Open the Cygwin shell or some other shell on a linux system
  4. Go to the project's folder
  5. Go to the NDK folder, e.g. cd /cygdrive/c/Users/Tobi/workspace/AndAR/jni
  6. Invoke the program called ndk-build(found inside the unzipped NDK folder), e.g. /opt/android-ndk-r4/ndk-build
  7. Refesh your project in Eclipse (right-click -> refresh)
  8. If everything went smoothly your libs/armeabi folder should contain .so files

Before NDK r4

  1. Install the android NDK
  2. (windows only) Install Cygwin
  3. Open the Cygwin shell or some other shell on a linux system
  4. Go to the NDK folder.
    • This is where you unzipped the android NDK.
    • e.g. you unzipped it to C:\cygwin do a cd /android-ndk.
  5. Create a symlink from your eclipse project folder (should be called AndOpenGLCam) to the ndk apps folder, e.g. ln -s /cygdrive/c/Users/Tobi/workspace/AndAR/ apps/AndAR (adapt the path)
  6. In the root of the NDK folder run make APP=AndOpenGLCam
  7. Refesh your project in Eclipse (right-click -> refresh)
  8. If everything went smoothly your libs/armeabi folder should contain .so files
Comment by fabio.an...@gmail.com, Apr 8, 2010

Any thoughts on supporting ARToolkitPlus 2.2.0 on your project?

Comment by project member tdomhan, Apr 9, 2010

I would, if android c++ wasn't that rubish... e.g. it doesn't support the STL

Comment by project member suzy...@gmail.com, Apr 13, 2010

So, some details on getting it to build on my system:

  • Windoze users: Make sure NDK is installed to a path with no spaces
  • Be sure to run build/host_setup.sh during NDK install
  • My symbolic link was: ln -s /cygdrive/c/mobileAR/andar-read-only/AndOpenGLCam apps/AndOpenGLCam
  • Before you make the native source, edit AndOpenGLCam/Application.mk, and change the project path, mine was: APP_PROJECT_PATH := /cygdrive/c/mobileAR/andar-read-only/AndOpenGLCam
  • In eclipse, i had some build errors that cleared up when i removed @Override from the function declaration
  • then i added camera_para.dat to the sdcard into the andar directory:
  • $ ./adb shell 
    $ cd sdcard 
    $ mkdir andar
    
    then 
    
    ./adb push camera_para.dat /sdcard/andar
Comment by fabio.an...@gmail.com, Apr 15, 2010

Then you should check this out, since this guy has patched the NDK toolchain to add STL support to it.

Comment by skrzy...@gmail.com, Apr 22, 2010

Here it is, support of ARToolkitPlus, I made this project page just to put there apk file right now http://code.google.com/p/andarplus/

Comment by fabio.an...@gmail.com, Apr 23, 2010

skrzy84, did you used the patched NDK? How about the ARToolkitPlus version? Is it 2.2? I'm waiting for that source code :)

Comment by skrzy...@gmail.com, Apr 23, 2010

exactly I used crystax NDK r3 and ARToolkitPlus 2.2.0, I can put it in a few days after clean-up, it will be modified andar from a month or two ago

Comment by project member tdomhan, Apr 23, 2010

pushing the camera calibration file to the sdcard is no longer needed.

Comment by Gnic...@gmail.com, Apr 26, 2010

do we still need to compile the native source for the new AndAR? cause i try to compile and libimageprocessing.so is missing ~

Comment by juanigna...@gmail.com, May 24, 2010

It won't compile under n4. ndk-build throws the following errors:

<workspace>/AndAR/jni/AR/arToolKi t.c:28:21: error: GLES/gl.h: No such file or directory <workspace>/AndAR/jni/AR/arToolKi t.c: In function 'Java_edu_dhbw_andar_ARToolkit_artoolkit_1detectmarkers': <workspace>/AndAR/jni/AR/arToolKi t.c:507: warning: passing argument 4 of 'arGetTransMat' from incompatible pointe r type <workspace>/AndAR/jni/AR/AR/ar.h: 408: note: expected 'double ()4?' but argument is of type 'double ' make: [<workspace>/AndAR/bin/ ndk/local/armeabi/objs/ar/arToolKit.o] Error 1

Comment by jorisdek...@gmail.com, Dec 16, 2010

I have the same problem while compiling the code: at arToolKit.c:510 warning: passing argument 4 of 'arGetTransMat' from incompatible pointer type ... ar.h:408: expected 'double()4?' but argument is of type 'double '

since I'm not getting it. Hopefully somebody is able to explain the problem/solution to me?

Comment by schouten...@gmail.com, Apr 26, 2011

I can't get C/C++ debugging in Eclipse to work with andarplus. STL is now supported with the latest NDK. So no need for the crystax mod anymore. First of all, I had to make some modifications to get andarplus to compile: -Move Application.mk to the jni folder. -Change the contents of Application.mk so that it only contains: APP_STL := stlport_shared APP_MODULES := arplus -Add System.loadLibrary("stlport_shared") to each location where a System.loadLibrary call is made. -Remove all header references from all make files at LOCAL_SRC_FILES

After this it compiles fine but the program crashes on my Samsung Nexus S (Android 2.3). So I want to debug it using Eclipse and the Sequoyah plugin. However, I get an error when running ndk-gdb: cp: target '/my/workspace/dir/obj/local/armeabi/gdb.setup' is not a directory /my/workspace/dir/obj/local/armeabi/gdb.setup: no such file or directory.

I managed to get C/C++ debugging to work in Eclipse using a simple hello-world program so I know the setup is ok. Any ideas?

Comment by schouten...@gmail.com, Apr 30, 2011

Update to my previous post: The Application.mk file should contain this line: APP_MODULES := arplus ar imageprocessing yuv420sp2rgb not just arplus as posted earlier. Not sure why the latest source (r25) commented this out. But now it crashes at another location: camera.startPreview(); I haven't figured out why it crashes. The error message is: CameraService? Overlay Creation Failed! I am downloading the Android source now to dive deep into the core. To be continued.

Comment by schouten...@gmail.com, Apr 30, 2011

Why does this page has absolutely no clue what an "enter" is? I tried both a normal enter and a shift-enter but the formatting is totally broken...

Comment by schouten...@gmail.com, May 6, 2011

I tried a few other open source projects which draws stuff on top of the camera image. A lot of them crash as well on Android 2.3. The problems is the way the layering is accomplished as there are several different ways to approach this. I have yet to find the "correct" way though.

In any case, I have decided to abandon this project for now. Partly because of lack of activity but mostly because I have found something much better. It is the Qualcomm QCAR API: http://developer.qualcomm.com/dev/augmented-reality They have a plugin for the Unity3d Android graphics engine and it makes it really easy to make amazing AR apps in no time. See this example which I have got to work too. It runs with 60fps on my Nexus S: http://www.youtube.com/watch?v=tNyc9h22lvU&feature=channel_video_title The tracking is way better quality and also way faster then AndAR (not sure about AndARPlus, I could not get it to work on my phone). Anyway, in the process of trying AndARPlus to work I have written a tutorial about how to debug C++ code on Android using Eclipse in Windows XP. You may find it of interest: http://pilotpage.monosock.org/fileadmin/files/Eclipse-cpp-tutorial.pdf

I hope the text formatting (enters) isn't destroyed again...


Sign in to add a comment
Powered by Google Project Hosting