在Android中包含Boost和OpenCV C ++库

时间:2014-09-04 11:55:22

标签: android opencv boost makefile

我是NDK的新手,必须将用C ++编写的项目移植到Android。该项目依赖于boostopencv库。

所以我开始创建一个Android项目并包含必要的NDK内容。我创建了一个Android.mk文件,并在描述中添加了库。

文件结构:

  • JNI
    • Android.mk
    • Application.mk
    • 升压
      • 包括
      • 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)

我正在使用Android NDK r8e boost 1_53和opencv2。

所以我尝试解决这个问题并遵循this guide,这也导致了错误。

这是我包含库的文件:

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;

我收到以下错误:

/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

我已经尝试了很多,而且我总是遇到一个库正在运行而另一个正在运行的问题。似乎有某种混淆。也许在我的make文件中?

我真的非常渴望在这方面工作几天,并感谢任何帮助。

0 个答案:

没有答案