g++编译使用到opencv: undefined reference to `cv::String::deallocate(),

g++编译一个包含opencv的文件,报错如下:
tinyyolopostprocessor.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
/tmp/cc9aMkWE.o: In function `cv::String::operator=(cv::String const&)':
tinyyolopostprocessor.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status

解决方案:编译指令后面添加指向openc的库,即命令最后加: `pkg-config  --cflags --libs opencv`。【注意用键盘左上角的单引号“ ` ”包含起来】

如果继续出现如下错误://home/wm/anaconda3/lib/libQt5Core.so.5: undefined reference to `u_errorName_58',

解决方案:

sudo vi /etc/profile
#打开文件的末尾添加:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/wm/anaconda3/lib

source /etc/profile

猜你喜欢

转载自blog.csdn.net/u010420283/article/details/109782425