我目前正在尝试构建和运行https://docs.opencv.org/trunk/de/d70/samples_2cpp_2kalman_8cpp-example.html#a12上的卡尔曼过滤器示例程序

当我尝试编译程序时,得到以下输出:

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

我似乎在我的Makefile中缺少链接库,但是我在网上到处都是,但似乎找不到它。

我尝试在我的Makefile的LIBS变量中切换链接库的顺序。我首先尝试在链接列表的末尾放置-lopencv_tracking(假定卡尔曼过滤器功能所在),然后尝试将其放置在链接列表的第二个位置(在-lopencv_core前面)。两者都产生相同的链接错误。

这是我正在使用的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)

该程序应正确构建,没有错误

最佳答案

我找到了答案,我的LIBS中缺少-lopencv_video

10-07 13:38