Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem compiling kalman filter program

Hello, I am having some trouble compiling the sample kalman filter program found on https://docs.opencv.org/trunk/de/d70/samples_2cpp_2kalman_8cpp-example.html#a12

I get the following output when I try to build the program

g++ -o  kalman kalman.o -lopencv_core -lopencv_tracking -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_objdetect
/usr/bin/ld: kalman.o: undefined reference to symbol '_ZN2cv12KalmanFilter7predictERKNS_3MatE'
/usr/bin/ld: /usr/lib/libopencv_video.so.4.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: kalman] Error 1

I am using my own Makefile for this, and this is the LIB variable in my makefile

LIBS=-lopencv_core -lopencv_tracking -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_objdetect

And just in case, here is my entire Makefile:

CC=g++
TARGET=kalman
SRC=kalman.cpp
LIBS=-lopencv_core -lopencv_tracking -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_objdetect
OBJ=kalman.o
%.o: %.cpp
        $(CC) -c -o $@ $< $(LIBS)
kalman: $(OBJ)
        $(CC) -o  $@ $^ $(LIBS)

The #includes for this program seem to suggest that the only libraries that are required to be linked are -lopencv_core, -lopencv_tracking, and -lopencv_highgui I originally had -lopencv_tracking as the very last library to link and I got the exact same error. I then promoted it to the second library to be linked and that yielded the same error.

Thanks!