我有一个OpenCV代码,我可以编译并成功运行代码块。但是当我通过这个命令(我在网上创建)从命令行尝试它时:
g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o binary main.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching
/usr/bin/ld: cannot find -lopencv_contrib
它给了我:
/ usr / bin / ld:找不到-lopencv_contrib / usr / bin / ld:找不到 -lopencv_legacy collect2:错误:ld返回1退出状态
当我尝试从命令中删除-lopencv_contrib -lopencv_legacy
时,它会给我:
/ usr / bin / ld:/tmp/ccL2lHM7.o:未定义的符号引用 '_ZN2cv6imreadERKNS_6StringEi' /usr/local/lib/libopencv_imgcodecs.so.3.4:错误添加符号:DSO 从命令行中丢失了collect2:错误:ld返回1退出状态
我使用Ubuntu 16.04和Opencv 3.4.1命令中的路径为true usr/local/include
和usr/local/lib
。