问题描述
我已使用以下命令从 OpenCV 官方代码版本4.2.0 成功配置了OpenCV:
pkg-config --cflags --libs opencv
配置后的输出为:
-I/home/blaster/installed/include/opencv4/opencv -I/home/blaster/installed/include/opencv4 -L/home/blaster/installed/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
配置后,我尝试使用以下命令在具有 Ubuntu 20.04.1 的设备上运行代码:
g++ `pkg-config --cflags --libs opencv` prog.cpp
并收到此错误:
cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char> > const&,int)'
/usr/bin/ld: prog.cpp:(.text+0x89): undefined reference to `cv::VideoCapture::isOpened() const'
/usr/bin/ld: prog.cpp:(.text+0xc1): undefined reference to `cv::VideoCapture::get(int) const'
/usr/bin/ld: prog.cpp:(.text+0x107): undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char,int)'
/usr/bin/ld: prog.cpp:(.text+0x15d): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)'
/usr/bin/ld: prog.cpp:(.text+0x1ed): undefined reference to `cv::imshow(std::__cxx11::basic_string<char,cv::_InputArray const&)'
/usr/bin/ld: prog.cpp:(.text+0x224): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: prog.cpp:(.text+0x264): undefined reference to `cv::VideoCapture::~VideoCapture()'
/usr/bin/ld: prog.cpp:(.text+0x363): undefined reference to `cv::VideoCapture::~VideoCapture()'
/usr/bin/ld: /tmp/cc6PCHzq.o: in function `cv::Mat::~Mat()':
prog.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3d): undefined reference to `cv::fastFree(void*)'
/usr/bin/ld: /tmp/cc6PCHzq.o: in function `cv::Mat::release()':
prog.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4f): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
该如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)