【问题标题】:Error while compiling/linking OpenCV Matlab source files编译/链接 OpenCV Matlab 源文件时出错
【发布时间】:2014-01-29 11:58:34
【问题描述】:

成功编译95%的OpenCV后报错

(...)
[ 95%] Built target opencv_videostab
[ 95%] Generating Matlab source files
[ 95%] Built target opencv_matlab_sources
[ 95%] Compiling Matlab source files. This could take a while...
CMake Error at compile.cmake:47 (message):
  Failed to compile logPolar: /usr/bin/ld: cannot find -lopencv_core

  /usr/bin/ld: cannot find -lopencv_imgproc

  /usr/bin/ld: cannot find -lopencv_ml

  /usr/bin/ld: cannot find -lopencv_highgui

  /usr/bin/ld: cannot find -lopencv_objdetect

  /usr/bin/ld: cannot find -lopencv_flann

  /usr/bin/ld: cannot find -lopencv_features2d

  /usr/bin/ld: cannot find -lopencv_photo

  /usr/bin/ld: cannot find -lopencv_video

  /usr/bin/ld: cannot find -lopencv_videostab

  /usr/bin/ld: cannot find -lopencv_calib3d

  /usr/bin/ld: cannot find -lopencv_stitching

  /usr/bin/ld: cannot find -lopencv_superres

  /usr/bin/ld: cannot find -lopencv_nonfree

  collect2: ld returned 1 exit status



      mex: link of ' "logPolar.mexa64"' failed.





make[2]: *** [modules/matlab/compile.proxy] Error 1
make[1]: *** [modules/matlab/CMakeFiles/opencv_matlab.dir/all] Error 2
make: *** [all] Error 2

这让我很困惑,因为据我所知,所有这些都应该在构建过程的早期编译。使用的 cmake 命令是

cmake -D MATLAB_ROOT_DIR=/usr/lib/matlab2012a/ -D CMAKE_INSTALL_PREFIX=/home/user ..

【问题讨论】:

    标签: opencv makefile cmake


    【解决方案1】:

    我遇到了同样的问题,我想它尚未包含在官方发行版中是有原因的。我的解决方案如下:

    1. 在没有 Matlab 模块的情况下编译 OpenCV,对我来说,这只是因为它不在标准位置,所以没有指定 Matlab 的位置,但应该可以通过在 cmake 中设置变量或修改 CMake 配置文件来实现。
    2. 安装 OpenCV(make install),这将安装必要的库。
    3. 再次运行 cmake,这次包括 Matlab 选项,运行 make。
    4. 此时,在编译一些生成的 Mex 源文件时会出现一堆错误。我只是删除了无法编译的文件。这些是我必须删除的文件:
    createAlignMTB.cpp
    createCalibrateDebevec.cpp
    createCalibrateRobertson.cpp
    createLineSegmentDetector.cpp
    createMergeDebevec.cpp
    createMergeMertens.cpp
    createMergeRobertson.cpp
    createTonemap.cpp
    createTonemapDrago.cpp
    createTonemapDurand.cpp
    createTonemapMantiuk.cpp
    createTonemapReinhard.cpp
    findCirclesGrid.cpp
    

    我不需要它们中的任何一个,希望你也一样,如果你需要,你需要解决错误。 (源文件似乎不会在生成后重新生成,因此可以安全地修改)

    1. 进行安装!
    2. ???
    3. 利润!

    【讨论】:

      【解决方案2】:
      When encountering an error with building something with cmake, it's always a good idea to rerun it with VERBOSE=1 option. 
      

      我遇到了与“/usr/bin/ld: 找不到 ....”类似的问题,并使 VERBOSE=1 显示 opencv 库的链接器路径被错误地设置为 L${ROOT_TO_OPENCV_BUILD}/lib/ RelWithDebInfo 而它应该是 L${ROOT_TO_OPENCV_BUILD}/lib。 所以问题出在 CMake 配置文件中。

      一个超级肮脏的解决方法是简单地创建一个像这样的假链接 cd ${ROOT_TO_OPENCV_BUILD}/lib; ln -s 。 RelWithDebInfo 这将使编译 continue.fails 为我稍后在 createTonemapReinhard.cpp 错误:“Ptr_TonemapReinhard”未在此范围内声明 显然 matlab mex 模块还没有准备好。

      【讨论】:

      • 我会试试这个。谢谢!
      猜你喜欢
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多