Linux OpenCV static Link error, linuxopencv
Error 1:
Undefined reference to 'dlopen'
Undefined referenceTo'Dlerror'
Undefined reference to 'dlsym'
Undefined reference to dlopen, dlerror, and dlsym. The Link Library is missing and the option-ldl is added to the link.
Refer:
Error 2:
For icvPuts and icvGets undefined references, the compilation error is as follows:
./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
If the zlib library is missing, add-lz to the compilation link.
Refer:
Summary: similar undefined reference errors are caused by missing libraries. When statically linking the OpenCV library, you must not only link libopencv _***. a, also requires libraries such as dl and zlib. When a similar error occurs, Google will directly undefined the library corresponding to the referenced function, and then add it to the link.