錯誤一:
undefined reference to `dlopen'
undefined reference to `dlerror'
undefined reference to `dlsym'
對dlopen, dlerror, dlsym 未定義的引用, 缺少鏈接庫, 鏈接時加上選項 -ldl
參考:
錯誤二:
對icvPuts, icvGets 未定義的引用,編譯錯誤如下:
./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' failedpersistence.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
缺少zlib庫引起的, 編譯鏈接時加上 -lz
參考:
總結: 類似的未定義的引用錯誤,應該都是由于缺少庫的原因引起的, 靜態鏈接OpenCV庫的時候, 不僅需要鏈接libopencv_***.a, 也需要 dl, zlib 等庫, 出現類似錯誤時, 直接Google 未定義引用的函數對應的庫, 然后在鏈接中添加上.
新聞熱點
疑難解答