xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.04k stars 785 forks source link

opencv版本错误 #899

Closed wangzhankun closed 4 years ago

wangzhankun commented 4 years ago

注:提问题时若使用不能用/没效果/有问题/报错此类模糊表达,但又没有根据下面的模板给出任何相关辅助信息的,将会直接标记为Invalid。

描述问题

在本地创建了一个新的环境。安装完opencv4之后发现环境问题,将其卸载后(sudo make uninstall),安装了opencv3版本(手动编译安装),在编译时出现链接错误如下(最后面)。但是xmake l find_packages opencv可以找到opencv,信息如下:

{ 
  { 
    links = { 
      "opencv_dnn",
      "opencv_highgui",
      "opencv_ml",
      "opencv_objdetect",
      "opencv_shape",
      "opencv_stitching",
      "opencv_superres",
      "opencv_videostab",
      "opencv_calib3d",
      "opencv_videoio",
      "opencv_imgcodecs",
      "opencv_features2d",
      "opencv_video",
      "opencv_photo",
      "opencv_imgproc",
      "opencv_flann",
      "opencv_viz",
      "opencv_core" 
    },
    linkdirs = { 
      "/usr/local/lib" 
    },
    version = "3.4.7",
    includedirs = { 
      "/usr/local/include/opencv",
      "/usr/local/include" 
    } 
  } 
}

当强制指定opencv版本之后add_requires("opencv 3.x"),报错如下:

checking for the gcc ... /usr/bin/gcc
checking for the unzip ... /usr/bin/unzip
checking for the git ... /usr/bin/git
checking for the gzip ... /bin/gzip
checking for the tar ... /bin/tar
checking for the ping ... /bin/ping
pinging for the host(gitee.com) ... 34 ms
pinging for the host(gitlab.com) ... 55 ms
checking for the nmap ... no
pinging for the host(github.com) ... 65535 ms
error: package(opencv): version conflict, '4.2.0' does not satisfy '3.x'!

不知道opencv版本时,报错如下:

configure
{
    arch = x86_64
    ccache = true
    mode = release
    ndk_stdcxx = true
    host = linux
    kind = static
    buildir = build
    plat = linux
}
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the linker (ld) ... g++
[ 95%]: linking.release CV
/usr/bin/g++ -o build/linux/x86_64/release/CV build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/release/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/release/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/release/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffDetector.cpp.o -s -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64
error: build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o: In function `showPicture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cv::Mat const&, int)':
actions.cpp:(.text+0x5a): undefined reference to `cv::String::allocate(unsigned long)'
actions.cpp:(.text+0x75): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
actions.cpp:(.text+0x7d): undefined reference to `cv::String::deallocate()'
actions.cpp:(.text+0x85): undefined reference to `cv::waitKey(int)'
actions.cpp:(.text+0xb0): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o: In function `GxCamera::getFrame()':
GxCamera.cpp:(.text+0x457): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o: In function `GxCamera::~GxCamera()':
GxCamera.cpp:(.text+0xa9a): undefined reference to `cv::fastFree(void*)'
GxCamera.cpp:(.text+0xae8): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o: In function `GxCamera::_config()':
GxCamera.cpp:(.text+0xd8e): undefined reference to `cv::Mat::create(int, int const*, int)'
GxCamera.cpp:(.text+0xf15): undefined reference to `cv::Mat::create(int, int const*, int)'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o: In function `cv::Mat::~Mat()':
GxCamera.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x89): undefined reference to `cv::Mat::deallocate()'
GxCamera.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x72): undefined reference to `cv::fastFree(void*)'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o: In function `RMVideoCapture::cvtRaw2Mat(void const*, cv::Mat&)':
RMVideoCapture.cpp:(.text+0x1c6): undefined reference to `cv::Mat::updateContinuityFlag()'
RMVideoCapture.cpp:(.text+0x1ec): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
RMVideoCapture.cpp:(.text+0x29b): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0x308): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0x382): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0x454): undefined reference to `cv::Mat::updateContinuityFlag()'
RMVideoCapture.cpp:(.text+0x494): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
RMVideoCapture.cpp:(.text+0x51d): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0x54c): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0x55c): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0x56c): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0x598): undefined reference to `cv::String::allocate(unsigned long)'
RMVideoCapture.cpp:(.text+0x5d9): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
RMVideoCapture.cpp:(.text+0x5e1): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0x628): undefined reference to `cv::String::allocate(unsigned long)'
RMVideoCapture.cpp:(.text+0x669): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
RMVideoCapture.cpp:(.text+0x671): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0x6cc): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0x6ec): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o: In function `RMVideoCapture::operator>>(cv::Mat&)':
RMVideoCapture.cpp:(.text+0x8fb): undefined reference to `cv::Mat::updateContinuityFlag()'
RMVideoCapture.cpp:(.text+0x921): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
RMVideoCapture.cpp:(.text+0x9d4): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0xa41): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0xac1): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0xb96): undefined reference to `cv::Mat::updateContinuityFlag()'
RMVideoCapture.cpp:(.text+0xbd6): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
RMVideoCapture.cpp:(.text+0xc5d): undefined reference to `cv::fastFree(void*)'
RMVideoCapture.cpp:(.text+0xc8c): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0xc9c): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0xcac): undefined reference to `cv::Mat::deallocate()'
RMVideoCapture.cpp:(.text+0xcd8): undefined reference to `cv::String::allocate(unsigned long)'
RMVideoCapture.cpp:(.text+0xd19): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
RMVideoCapture.cpp:(.text+0xd21): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0xd70): undefined reference to `cv::String::allocate(unsigned long)'
RMVideoCapture.cpp:(.text+0xdb1): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
RMVideoCapture.cpp:(.text+0xdb9): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0xe04): undefined reference to `cv::String::deallocate()'
RMVideoCapture.cpp:(.text+0xe4a): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o: In function `OrdinaryCamera::getFrame()':
OrdinaryCapture.cpp:(.text+0x25): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
OrdinaryCapture.cpp:(.text+0xa4): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o: In function `OrdinaryCamera::OrdinaryCamera(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
OrdinaryCapture.cpp:(.text+0x1df): undefined reference to `cv::VideoCapture::VideoCapture()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o: In function `OrdinaryCamera::~OrdinaryCamera()':
OrdinaryCapture.cpp:(.text+0x427): undefined reference to `cv::fastFree(void*)'
OrdinaryCapture.cpp:(.text+0x434): undefined reference to `cv::VideoCapture::~VideoCapture()'
OrdinaryCapture.cpp:(.text+0x465): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o: In function `OrdinaryCamera::open()':
OrdinaryCapture.cpp:(.text+0x4bb): undefined reference to `cv::String::allocate(unsigned long)'
OrdinaryCapture.cpp:(.text+0x4d4): undefined reference to `cv::VideoCapture::open(cv::String const&)'
OrdinaryCapture.cpp:(.text+0x4dc): undefined reference to `cv::String::deallocate()'
OrdinaryCapture.cpp:(.text+0x4e4): undefined reference to `cv::VideoCapture::isOpened() const'
OrdinaryCapture.cpp:(.text+0x516): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o: In function `VirtualCamera::VirtualCamera(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
VirtualCamera.cpp:(.text+0x12c): undefined reference to `cv::VideoCapture::VideoCapture()'
VirtualCamera.cpp:(.text+0x250): undefined reference to `cv::VideoCapture::~VideoCapture()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o: In function `VirtualCamera::~VirtualCamera()':
VirtualCamera.cpp:(.text+0x298): undefined reference to `cv::VideoCapture::~VideoCapture()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o: In function `VirtualCamera::open()':
VirtualCamera.cpp:(.text+0x31b): undefined reference to `cv::String::allocate(unsigned long)'
VirtualCamera.cpp:(.text+0x334): undefined reference to `cv::VideoCapture::open(cv::String const&)'
VirtualCamera.cpp:(.text+0x33c): undefined reference to `cv::String::deallocate()'
VirtualCamera.cpp:(.text+0x344): undefined reference to `cv::VideoCapture::isOpened() const'
VirtualCamera.cpp:(.text+0x374): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o: In function `VirtualCamera::getFrame()':
VirtualCamera.cpp:(.text+0x418): undefined reference to `cv::VideoCapture::read(cv::_OutputArray const&)'
build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o: In function `Controller::getImageFromCamera()':
Controller.cpp:(.text+0xee2): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0xf4d): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0xfe6): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
Controller.cpp:(.text+0x10b2): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0x111c): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0x128c): undefined reference to `cv::Mat::deallocate()'
Controller.cpp:(.text+0x12a0): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o: In function `Controller::mainpulatePicture()':
Controller.cpp:(.text+0x14b3): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0x1664): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
Controller.cpp:(.text+0x1854): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o: In function `Controller::Controller()':
Controller.cpp:(.text+0x1f04): undefined reference to `cv::VideoWriter::VideoWriter()'
Controller.cpp:(.text+0x1f18): undefined reference to `cv::VideoWriter::VideoWriter()'
Controller.cpp:(.text+0x2262): undefined reference to `cv::VideoWriter::~VideoWriter()'
Controller.cpp:(.text+0x226c): undefined reference to `cv::VideoWriter::~VideoWriter()'
build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o: In function `Controller::~Controller()':
Controller.cpp:(.text+0x23aa): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0x2442): undefined reference to `cv::fastFree(void*)'
Controller.cpp:(.text+0x24e2): undefined reference to `cv::VideoWriter::~VideoWriter()'
Controller.cpp:(.text+0x24ee): undefined reference to `cv::VideoWriter::~VideoWriter()'
Controller.cpp:(.text+0x2580): undefined reference to `cv::Mat::deallocate()'
Controller.cpp:(.text+0x2598): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::~SentryArmorDetector()':
SentryArmorDetector.cpp:(.text+0x672): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x70a): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x7f8): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text+0x810): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::drawRRects(cv::Mat&, std::vector<cv::RotatedRect, std::allocator<cv::RotatedRect> >)':
SentryArmorDetector.cpp:(.text+0xb12): undefined reference to `cv::RotatedRect::points(cv::Point_<float>*) const'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::colorThres(cv::Mat&)':
SentryArmorDetector.cpp:(.text+0xc6b): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
SentryArmorDetector.cpp:(.text+0xca8): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
SentryArmorDetector.cpp:(.text+0xd07): undefined reference to `cv::split(cv::_InputArray const&, cv::_OutputArray const&)'
SentryArmorDetector.cpp:(.text+0xd51): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
SentryArmorDetector.cpp:(.text+0xdb1): undefined reference to `cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)'
SentryArmorDetector.cpp:(.text+0xdb6): undefined reference to `cv::noArray()'
SentryArmorDetector.cpp:(.text+0xe40): undefined reference to `cv::subtract(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, int)'
SentryArmorDetector.cpp:(.text+0xea0): undefined reference to `cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)'
SentryArmorDetector.cpp:(.text+0xec4): undefined reference to `cv::operator&(cv::Mat const&, cv::Mat const&)'
SentryArmorDetector.cpp:(.text+0xedd): undefined reference to `cv::operator-(cv::Mat const&, cv::MatExpr const&)'
SentryArmorDetector.cpp:(.text+0xf89): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x1019): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x10a6): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x1131): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x11c1): undefined reference to `cv::fastFree(void*)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o:SentryArmorDetector.cpp:(.text+0x124e): more undefined references to `cv::fastFree(void*)' follow
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::colorThres(cv::Mat&)':
SentryArmorDetector.cpp:(.text+0x12b5): undefined reference to `cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)'
SentryArmorDetector.cpp:(.text+0x1362): undefined reference to `cv::dilate(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
SentryArmorDetector.cpp:(.text+0x1400): undefined reference to `cv::dilate(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
SentryArmorDetector.cpp:(.text+0x1416): undefined reference to `cv::operator&(cv::Mat const&, cv::Mat const&)'
SentryArmorDetector.cpp:(.text+0x14c1): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x1551): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x15de): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x1675): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text+0x1705): undefined reference to `cv::fastFree(void*)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o:SentryArmorDetector.cpp:(.text+0x1795): more undefined references to `cv::fastFree(void*)' follow
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::colorThres(cv::Mat&)':
SentryArmorDetector.cpp:(.text+0x1934): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text+0x1941): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text+0x1952): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text+0x1960): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text+0x196e): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o:SentryArmorDetector.cpp:(.text+0x197f): more undefined references to `cv::Mat::deallocate()' follow
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::filterContours()':
SentryArmorDetector.cpp:(.text+0x1edd): undefined reference to `cv::minAreaRect(cv::_InputArray const&)'
SentryArmorDetector.cpp:(.text+0x1f8d): undefined reference to `cv::fitEllipse(cv::_InputArray const&)'
SentryArmorDetector.cpp:(.text+0x1fdc): undefined reference to `cv::ellipse(cv::_InputOutputArray const&, cv::RotatedRect const&, cv::Scalar_<double> const&, int, int)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `SentryArmorDetector::getCenter(cv::Mat&, TargetData&)':
SentryArmorDetector.cpp:(.text+0x3018): undefined reference to `cv::findContours(cv::_InputOutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int, cv::Point_<int>)'
SentryArmorDetector.cpp:(.text+0x309f): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
SentryArmorDetector.cpp:(.text+0x3544): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `cv::MatExpr::~MatExpr()':
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x9a): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x127): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x1ad): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x1c0): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x1d5): undefined reference to `cv::Mat::deallocate()'
SentryArmorDetector.cpp:(.text._ZN2cv7MatExprD2Ev[_ZN2cv7MatExprD5Ev]+0x19a): undefined reference to `cv::fastFree(void*)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o: In function `std::vector<cv::Mat, std::allocator<cv::Mat> >::~vector()':
SentryArmorDetector.cpp:(.text._ZNSt6vectorIN2cv3MatESaIS1_EED2Ev[_ZNSt6vectorIN2cv3MatESaIS1_EED5Ev]+0xc1): undefined reference to `cv::fastFree(void*)'
SentryArmorDetector.cpp:(.text._ZNSt6vectorIN2cv3MatESaIS1_EED2Ev[_ZNSt6vectorIN2cv3MatESaIS1_EED5Ev]+0x10c): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o: In function `SentryAngleCalculate::pnpSolver(cv::RotatedRect&, cv::RotatedRect&, TargetData&)':
SentryAngleCalculate.cpp:(.text+0x698): undefined reference to `cv::Mat::zeros(int, int, int)'
SentryAngleCalculate.cpp:(.text+0x798): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0x820): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0x89e): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0x8b9): undefined reference to `cv::Mat::zeros(int, int, int)'
SentryAngleCalculate.cpp:(.text+0x9c0): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0xa40): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0xabe): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0xb2f): undefined reference to `cv::RotatedRect::points(cv::Point_<float>*) const'
SentryAngleCalculate.cpp:(.text+0xb3e): undefined reference to `cv::RotatedRect::points(cv::Point_<float>*) const'
SentryAngleCalculate.cpp:(.text+0x105b): undefined reference to `cv::solvePnP(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, bool, int)'
SentryAngleCalculate.cpp:(.text+0x1297): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0x130f): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text+0x174c): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text+0x175c): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text+0x1774): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text+0x178c): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text+0x17a7): undefined reference to `cv::Mat::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o:SentryAngleCalculate.cpp:(.text+0x17bc): more undefined references to `cv::Mat::deallocate()' follow
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o: In function `cv::Mat_<float>::~Mat_()':
SentryAngleCalculate.cpp:(.text._ZN2cv4Mat_IfED2Ev[_ZN2cv4Mat_IfED5Ev]+0x72): undefined reference to `cv::fastFree(void*)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o: In function `cv::MatConstIterator::operator++()':
SentryAngleCalculate.cpp:(.text._ZN2cv16MatConstIteratorppEv[_ZN2cv16MatConstIteratorppEv]+0x38): undefined reference to `cv::MatConstIterator::seek(long, bool)'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o: In function `_GLOBAL__sub_I_intrinsic_matrix_8_640':
SentryAngleCalculate.cpp:(.text.startup+0xc9): undefined reference to `cv::Mat::create(int, int const*, int)'
SentryAngleCalculate.cpp:(.text.startup+0x169): undefined reference to `cv::MatConstIterator::seek(int const*, bool)'
SentryAngleCalculate.cpp:(.text.startup+0x33a): undefined reference to `cv::String::allocate(unsigned long)'
SentryAngleCalculate.cpp:(.text.startup+0x36c): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
SentryAngleCalculate.cpp:(.text.startup+0x374): undefined reference to `cv::String::deallocate()'
SentryAngleCalculate.cpp:(.text.startup+0x3a8): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
SentryAngleCalculate.cpp:(.text.startup+0x8d3): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
SentryAngleCalculate.cpp:(.text.startup+0x91e): undefined reference to `cv::Mat::reshape(int, int, int const*) const'
SentryAngleCalculate.cpp:(.text.startup+0x977): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
SentryAngleCalculate.cpp:(.text.startup+0xa01): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text.startup+0xa6c): undefined reference to `cv::Mat::reshape(int, int, int const*) const'
SentryAngleCalculate.cpp:(.text.startup+0xaf0): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text.startup+0xb75): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text.startup+0xbc1): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text.startup+0xc4a): undefined reference to `cv::fastFree(void*)'
SentryAngleCalculate.cpp:(.text.startup+0xcc7): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text.startup+0xd6e): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text.startup+0xd7f): undefined reference to `cv::Mat::deallocate()'
SentryAngleCalculate.cpp:(.text.startup+0xdc9): undefined reference to `cv::String::deallocate()'
build/.objs/CV/linux/x86_64/release/Sentry/src/SentryPictureManipulator.cpp.o: In function `SentryPictureManipulator::manipulatePicture(cv::Mat)':
SentryPictureManipulator.cpp:(.text+0x2eb): undefined reference to `cv::fastFree(void*)'
SentryPictureManipulator.cpp:(.text+0x3b1): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
SentryPictureManipulator.cpp:(.text+0x3c4): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status

期待的结果

希望能够正常编译。个人认为可能是远程仓库的锅。因为我在本地安装的是opencv4.4.0和opencv3.4.7的版本,不存在报错中的4.2版本的问题。

相关环境

wangzhankun commented 4 years ago

关于链接报错问题,感觉跟我原先在这个issue提到的问题很像。但是那个问题的解决结果是安装动态链接库解决了。而这次我的opencv安装的确实是动态链接的,ls /usr/local/lib输出结果如下

cmake               libluajit-5.1.so.2          libopencv_dnn.so.3.4.7         libopencv_imgcodecs.so        libopencv_objdetect.so.3.4    libopencv_stitching.so.3.4.7  libopencv_videostab.so
libcjson.so         libluajit-5.1.so.2.0.4      libopencv_features2d.so        libopencv_imgcodecs.so.3.4    libopencv_objdetect.so.3.4.7  libopencv_superres.so         libopencv_videostab.so.3.4
libcjson.so.1       libopencv_calib3d.so        libopencv_features2d.so.3.4    libopencv_imgcodecs.so.3.4.7  libopencv_photo.so            libopencv_superres.so.3.4     libopencv_videostab.so.3.4.7
libcjson.so.1.7.13  libopencv_calib3d.so.3.4    libopencv_features2d.so.3.4.7  libopencv_imgproc.so          libopencv_photo.so.3.4        libopencv_superres.so.3.4.7   libopencv_viz.so
libjemalloc.a       libopencv_calib3d.so.3.4.7  libopencv_flann.so             libopencv_imgproc.so.3.4      libopencv_photo.so.3.4.7      libopencv_videoio.so          libopencv_viz.so.3.4
libjemalloc_pic.a   libopencv_core.so           libopencv_flann.so.3.4         libopencv_imgproc.so.3.4.7    libopencv_shape.so            libopencv_videoio.so.3.4      libopencv_viz.so.3.4.7
libjemalloc.so      libopencv_core.so.3.4       libopencv_flann.so.3.4.7       libopencv_ml.so               libopencv_shape.so.3.4        libopencv_videoio.so.3.4.7    lua
libjemalloc.so.2    libopencv_core.so.3.4.7     libopencv_highgui.so           libopencv_ml.so.3.4           libopencv_shape.so.3.4.7      libopencv_video.so            pkgconfig
libluajit-5.1.a     libopencv_dnn.so            libopencv_highgui.so.3.4       libopencv_ml.so.3.4.7         libopencv_stitching.so        libopencv_video.so.3.4        python2.7
libluajit-5.1.so    libopencv_dnn.so.3.4        libopencv_highgui.so.3.4.7     libopencv_objdetect.so        libopencv_stitching.so.3.4    libopencv_video.so.3.4.7      python3.6
wangzhankun commented 4 years ago

奇怪,不知道为啥,现在执行成功了又,可以正常编译了。就是打开了打开了vscode,然后第一次编译还是失败,当再次把add_requires("opencv 3.x")改成add_requires("opencv")并在debug模式下进行编译就成功了(使用的是插件)。不知道可能的原因在哪里。在此之前搞了好久都是无法编译。 image

waruqi commented 4 years ago

首先,你来回切add_requires版本的时候,记得 xmake f -c 带 -c 强制清下配置cache,触发重新检测依赖包,不然会使用缓存的结果

error: package(opencv): version conflict, '4.2.0' does not satisfy '3.x'!

这个通常是由于,其他依赖包里面可能也add_deps指定了3.x的opencv依赖,或者其他地方还有 add_requries opencv 的依赖,导致版本冲突了,你可以找找

/usr/bin/g++ -o build/linux/x86_64/release/CV build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/release/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/release/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/release/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffDetector.cpp.o -s -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64 error: build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o: In function showPicture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cv::Mat const&, int)': actions.cpp:(.text+0x5a): undefined reference tocv::String::allocate(unsigned long)' a

这个错误,你看下输出里面的实际link命令,opencv的库没有link进去,可以按刚说的 强制 xmake f -c 清下cache触发重新检测试试

另外,既然你本地有装,不想用远程的包,你可以人为指定不远程下载 add_requires("opencv", {system = true}) 仅从系统探测使用

默认模式是先从系统探测(指定了4.x就会探测系统对应版本,不匹配也会忽略),如果探测不到就会自动从远程下载

wangzhankun commented 4 years ago

主要是无法链接问题的解决方案我很奇怪。因为当时尝试了很多种方法。sudo ldconfig重启都试了都是不行。opencv也重装了几遍也是不可以,就是启动vscode之后使用插件尝试编译就成功了。不知道可能问题在哪里。现在link是正常的。按我当时贴的报错的话,应该是没链接上的。正常的链接信息如下:

/usr/bin/g++ -o build/linux/x86_64/debug/CV build/.objs/CV/linux/x86_64/debug/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/debug/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/OrdinaryCapture.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/debug/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/Detector.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffDetector.cpp.o -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib -lopencv_dnn -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64

可以看到最后面是链接了opencv的,但是在之前的报错中似乎是没有正常链接。

waruqi commented 4 years ago

主要是无法链接问题的解决方案我很奇怪。因为当时尝试了很多种方法。sudo ldconfig重启都试了都是不行。opencv也重装了几遍也是不可以,就是启动vscode之后使用插件尝试编译就成功了。不知道可能问题在哪里。现在link是正常的。按我当时贴的报错的话,应该是没链接上的。正常的链接信息如下:

/usr/bin/g++ -o build/linux/x86_64/debug/CV build/.objs/CV/linux/x86_64/debug/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/debug/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/OrdinaryCapture.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/debug/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/Detector.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffDetector.cpp.o -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib -lopencv_dnn -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64

可以看到最后面是链接了opencv的,但是在之前的报错中似乎是没有正常链接。

通常是配置缓存问题,所以你可以按我之前说的xmake f -c 强制忽略历史缓存,重新检测所有就好,

wangzhankun commented 4 years ago

好的,谢谢