1

I am very new to the NDK and have to port a project written in C++ to Android. The project is relying on the boost and opencv libraries.

So I started by creating an Android project and including the necessary NDK stuff. I created an Android.mk file and added the libraries like in the descriptions.

File structure:

  • jni
    • Android.mk
    • Application.mk
    • boost
      • include
      • lib
        • boost.mk
        • libboost_date_time-gcc-mt-1_53.a
        • ...
    • opencv
      • ...

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include ./jni/opencv/sdk/native/jni/OpenCV.mk

LOCAL_MODULE           := wahet
LOCAL_SRC_FILES        := wahet.cpp

LOCAL_CFLAGS += -I./jni/boost/include/boost-1_53
LOCAL_LDLIBS += -L./jni/boost/lib/ -libboost_system-gcc-mt-1_53.a -libboost_regex-gcc-mt-1_53.a -libboost_filesystem-gcc-mt-1_53.a -libboost_date_time-gcc-mt-1_53.a \
-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
-lgnustl_static

include $(BUILD_SHARED_LIBRARY)

I am using Android NDK r8e boost 1_53 and opencv2.

So I tried to fix this and followed this guide, what resulted in errors as well.

This is my file where I include the libraries:

wahet.cpp

#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <ctime>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/photo/photo.hpp>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>

using namespace std;
using namespace cv;

And I get the following error:

/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /home/tassilo/android-ndks/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO jni/opencv/sdk/native/jni/../libs/armeabi-v7a/libopencv_java.so
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -libboost_system-gcc-mt-1_53.a
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -libboost_regex-gcc-mt-1_53.a
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -libboost_filesystem-gcc-mt-1_53.a
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -libboost_date_time-gcc-mt-1_53.a
/home/tassilo/android-ndks/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lgnustl_static

I already tried a lot and I always have the problem that there is one library working and the other one is'nt. it seems there is some kind of confilct. Maybe in my make files?

I am getting really desperated of working for days on this and appreciate any help.

Community
  • 1
  • 1
4ndro1d
  • 2,926
  • 7
  • 35
  • 65

0 Answers0