Ask Your Question
0

Linking error to -lopencv_core

asked 2017-12-15 19:50:06 -0600

Mhd gravatar image

updated 2017-12-17 16:59:36 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-16 01:51:48 -0600

berak gravatar image

it seems, opencv expects a different version of zlib, than you have on your box.

try to use the 3rdparty zlib, that comes with the opencv sources, instead:

cmake -DBUILD_ZLIB=ON

you'll have to re-run cmake, and rebuild the opencv libs.

edit flag offensive delete link more

Comments

Thanks for your reply. Actually, I added -lz to the end of OPENCV_LIB in my makefile. Unfortunately, I am now getting another very long error message related to -lopencv_highgui, the first few lines of this message are:

CXX/LD -o build/PangaeaTracking/bin/PangaeaTracking_console /usr/local/lib/libopencv_highgui.a(grfmt_jpeg2000.cpp.o): In function `cv::JasperInitializer::~JasperInitializer()':

I have no clue about what the problem could be!.

Mhd gravatar imageMhd ( 2017-12-17 14:04:30 -0600 )edit

it's a similar problem, -- libs that don't fit. if you don't absolutely need jpeg2000 support, disable it:

cmake -DWITH_JASPER=OFF -DBUILD_JASPER=OFF
berak gravatar imageberak ( 2017-12-18 01:32:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-15 19:50:06 -0600

Seen: 2,159 times

Last updated: Dec 17 '17