[英]Link error when compiling sample opencv kalman filter program
I am currently trying to build and run the kalman filter example program found on https://docs.opencv.org/trunk/de/d70/samples_2cpp_2kalman_8cpp-example.html#a12 我目前正在尝试构建和运行在https://docs.opencv.org/trunk/de/d70/samples_2cpp_2kalman_8cpp-example.html#a12上找到的卡尔曼过滤器示例程序
When I try to compile the program, I get the following output: 当我尝试编译程序时,得到以下输出:
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 seem to be missing a link library in my Makefile, but I have looked everywhere online and I can't seem to find it. 我似乎在我的Makefile中缺少链接库,但是我在网上到处都看过,但似乎找不到它。
I have tried switching the order of the link libraries in the LIBS variable of my Makefile. 我试图在我的Makefile的LIBS变量中切换链接库的顺序。 I first tried putting -lopencv_tracking (where I assume the kalman filter functions are) at the end of the link list, and then I tried putting it second in the list (right in front of -lopencv_core).
我首先尝试将-lopencv_tracking(我认为是卡尔曼过滤器功能所在的位置)放在链接列表的末尾,然后又尝试将其放在列表的第二位置(就在-lopencv_core的前面)。 Both yielded the same link error.
两者都产生相同的链接错误。
Here is the Makefile that I am using 这是我正在使用的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 program should build correctly with no errors 该程序应正确构建,没有错误
我找到了答案,我的LIBS中缺少-lopencv_video
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.