mad
mad

Reputation: 2789

Opencv + Boost: Undefined references

I have a computer vision source code that is related to find copy and move portions in a forged image. I cannot compile this source code that uses openCV and Boost, some of the errors include undefined references to OpenCv stuff, for example:.

main.cpp:(.text+0x3cc1): undefined reference to `cvSetZero'

My makefile is the following. I think I correctly indicate the boost and opencv libraries. What could be wrong?

# Boost library is required
BOOST_LIBS=-L/usr/include/boost -lboost_system  -lboost_random
BOOST_INCLUDE=-I/usr/include/boost
BOOST_VERSION=103500

OPENCV_INCLUDE=-I/usr/include/opencv2/ 
OPENCV_LIBS=-L/usr/include/opencv2/ -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_flann -lopencv_calib3d

Upvotes: 0

Views: 208

Answers (3)

01zhou
01zhou

Reputation: 334

if you have pkg-config installed, and if it knows where OpenCV is, you can try

OPENCV_INCLUDE=$$(pkg-config --cflags opencv)
OPENCV_LIBS=$$(pkg-config --libs opencv)

Upvotes: 0

Simson
Simson

Reputation: 824

You might want to check if OpenCV is installed correctly and where this installation is located. Afterwards you can adjust your makefile. How to do this depends on your OS.

E.g. on Linux you might want to search for the opencv_core.so (e.g. via locate -b opencv_core).

In my case it would be

OPENCV_LIBS=-L/usr/lib/ -lopencv_core

Upvotes: 0

berak
berak

Reputation: 39806

OPENCV_LIBS=-L/usr/lib/opencv2/ -lopencv_core ...
                   ^^^

Upvotes: 2

Related Questions