2012-06-01 51 views
3

我目前面臨的問題與展示in this question相同,只是我使用的是2.4版而不是2.3.1。使用Android Native Native Activity的OpenCV2.4

我已經將原生活動(從ndk樣本)轉換爲C++並修改了android.mk和application.mk。

我有同樣的錯誤(與〜馬特等等)。

當我讀到問題的答案時,我意識到我需要添加OPENCV_INSTALL_MODULES:=on and OPENCV_LIB_TYPE:=STATIC(這是奇怪的,因爲我有一個其他項目與本地openCV不需要這兩條線)。

但它仍然無法正常工作。

Android.mk如下:

LOCAL_PATH := $(call my-dir) 

include $(CLEAR_VARS) 

OPENCV_LIB_TYPE:=STATIC 
OPENCV_INSTALL_MODULES:=on 

include includeOpenCV.mk 

ifeq ("$(wildcard $(OPENCV_MK_PATH))","") 
    #try to load OpenCV.mk from default install location 
    include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk 
else 
    include $(OPENCV_MK_PATH) 
endif 

LOCAL_MODULE := native-activity 
LOCAL_SRC_FILES := main.cpp engine.cpp 
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM 
LOCAL_STATIC_LIBRARIES += android_native_app_glue 


include $(BUILD_SHARED_LIBRARY) 

$(call import-module,android/native_app_glue) 

,我發現了以下錯誤:

./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvPuts(CvFileStorage*, char const*)': 
persistence.cpp:(.text._ZL7icvPutsP13CvFileStoragePKc+0x20): undefined reference to `gzputs' 
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvGets(CvFileStorage*, char*, int)': 
persistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x26): undefined reference to `gzgets' 
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `icvXMLSkipSpaces(CvFileStorage*, char*, int)': 
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x1e2): undefined reference to `gzgets' 
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x208): undefined reference to `gzeof' 
persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x33c): undefined reference to `gzeof' 
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `_ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3': 
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x124): undefined reference to `gzgets' 
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x170): undefined reference to `gzeof' 
/cygdrive/d/soft/NVPACK/android-ndk-r7c/build/core/build-binary.mk:366: recipe for target `obj/local/armeabi-v7a/libnative-activity.so' failed 
persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii.clone.3+0x28e): undefined reference to `gzeof' 
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cvReleaseFileStorage': 
persistence.cpp:(.text.cvReleaseFileStorage+0x24): undefined reference to `gzclose' 
./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): In function `cvOpenFileStorage': 
persistence.cpp:(.text.cvOpenFileStorage+0x66e): undefined reference to `gzopen' 
persistence.cpp:(.text.cvOpenFileStorage+0x8fc): undefined reference to `gzclose' 
persistence.cpp:(.text.cvOpenFileStorage+0xaea): undefined reference to `gzrewind' 
persistence.cpp:(.text.cvOpenFileStorage+0xbee): undefined reference to `gzrewind' 
persistence.cpp:(.text.cvOpenFileStorage+0xc0a): undefined reference to `gzclose' 
collect2: ld returned 1 exit status 
make: *** [obj/local/armeabi-v7a/libnative-activity.so] Error 1 

有什麼我錯過了嗎?

回答

5

嘗試用

LOCAL_LDLIBS += -llog -landroid -lEGL -lGLESv1_CM 
+0

此修正我沒有以前的錯誤了固定它,但代之以: 由於無效的APK文件導致安裝失敗! 請檢查logcat輸出瞭解更多詳情。 發佈取消! 在日誌中:http://pastebin.com/Brj3n1BB – Tonial

+0

我結束了嘗試與本地等離子項目(其中顯示完成通過寫入位圖),它運作良好.... – Tonial

-1

我結束了與本土等離子項目(其中顯示是通過位圖寫入完成)試圖取代

LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM 

,效果不錯。

也許GLES搞混了OpenCV。我不認爲這兩個項目之間有任何其他差異。

以某種方式解決了問題。不過,如果有人遇到同樣的問題並解決它,我會有興趣瞭解是什麼原因造成的,以及如何解決這個問題。

5

儘管這是一個老問題,我遇到了同樣的問題,並通過添加

LOCAL_LDLIBS += -lz # Compression library 

要我Android.mk