Linking error to -lopencv_core
Hello,
I downloaded a code recently from a Github repo for doing non-rigid 3D object reconstruction from videos. The code has many dependencies on other libraries, among which is the OpenCV library. Unfortunately, when I build the code, I get the following error message:
CXX/LD -o build/PangaeaTracking/bin/PangaeaTracking_console /usr/bin/ld: /usr/local/lib/libopencv_core.a(persistence.cpp.o): undefined reference to symbol 'gzclose' //lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Makefile:127: recipe for target 'build/PangaeaTracking/bin/PangaeaTracking_console' failed make: * [build/PangaeaTracking/bin/PangaeaTracking_console] Error 1
I am building it on Ubuntu 16.04 and have installed opencv 2.4.13 correctly, made sure that this the case as follows: $ pkg-config --cflags opencv -I/usr/local/include/opencv -I/usr/local/include
The library dependencies in my makefile are:
Library dependencies
GL_LIB := -lGL -lGLU -lX11 -lGLEW
WX_LIB := wx-config --libs --gl-libs
BOOST_LIB := -lboost_filesystem -lboost_system -lboost_thread
OPENCV_LIB := -lopencv_core -lopencv_highgui -lopencv_imgproc
CERES_LIB := -lceres -lglog -ltbb -ltbbmalloc -lcholmod -lccolamd \ -lcamd -lcolamd -lamd -lsuitesparseconfig -llapack -lf77blas -latlas
LMDB_LIB := -llmdb
HDF5_LIB := -lhdf5_hl -lhdf5
LIBRARY_DIRS += $(LIB_BUILD_DIR) LDFLAGS := $(WX_LIB) $(BOOST_LIB) $(OPENCV_LIB) $(CERES_LIB) $(GL_LIB) $(LMDB_LIB) $(HDF5_LIB) LDFLAGS += $(foreach library_dir, $(LIBRARY_DIRS), -L$(library_dir))
I would be grateful if anybody has an idea about the possible cause of this error.
Update:
I realized that when I installed opencv from source, I passed the following parameters to the cmake:
$ cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -DWITH_OPENGL=ON -D BUILD_FAT_JAVA_LIB=ON -D INSTALL_TO_MANGLED_PATHS=ON -D INSTALL_CREATE_DISTRIB=ON -D INSTALL_TESTS=ON -D ENABLE_FAST_MATH=ON -D WITH_IMAGEIO=ON -D BUILD_SHARED_LIBS=OFF -D WITH_GSTREAMER=ON ..
So, I uninstalled opencv and reinstalled it with changing BUILD_SHARED_LIBS to ON instead. Now, I am facing different issue. The pkg-config cannot find opencv.pc file. I created the opencv.pc and added it to the pkgconfig folder. However, when I build my original code, I get the following error:
CXX src/main_engine/image_source/ImagesBufferReader.cpp In file included from ./include/main_engine/image_source/ImageSourceEngine.h:4:0, from src/main_engine/image_source/ImagesBufferReader.cpp:1: ./include/main_engine/image_source/../utils/global.h:17:30: fatal error: opencv2/opencv.hpp: No such file or directory compilation terminated. Makefile:155: recipe for target 'build/PangaeaTracking/src/main_engine/image_source/ImagesBufferReader.o' failed make: * [build/PangaeaTracking/src/main_engine/image_source/ImagesBufferReader.o] Error 1