zoukankan      html  css  js  c++  java
  • Caffe 编译: undefined reference to imencode()


    本系列文章由 @yhl_leo 出品,转载请注明出处。
    文章链接: http://blog.csdn.net/yhl_leo/article/details/52150781


    整理之前编译工程中遇到的一个Bug,贴上提示log信息:

    ...
    
    CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
    make: *** Waiting for unfinished jobs....
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/convert_imageset.bin] Error 1
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/compute_image_mean.bin] Error 1
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/caffe.bin] Error 1
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/extract_features.bin] Error 1
    .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
    .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/examples/siamese/convert_mnist_siamese_data.bin] Error 1
    
    ...

    很明显是OpenCV出了问题,网上查阅后,得知是因为lib文件opencv_imgcodecsMakefile文件中未添加,修改如下:

    LIBRARIES += glog gflags protobuf leveldb snappy 
        lmdb boost_system hdf5_hl hdf5 m 
        opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

    此外,还有一些Makefile文件这么写,也是可行的:

    ifeq ($(USE_OPENCV), 1)
        LIBRARIES += opencv_core opencv_highgui opencv_imgproc 
    
        ifeq ($(OPENCV_VERSION), 3)
            LIBRARIES += opencv_imgcodecs
        endif
    
    endif
  • 相关阅读:
    Vue + Element 中的时间自定义选择框的数据传参绑定分析与js格式化时间参数
    vue 给data 数据的重新初始化
    Vue + Element 后台项目与后台的数据对接
    js将两组数据存到你定义的空的对象数组
    Element ui 自定义表格行样式
    vue组件的注册与使用
    Vue + Element 实现下拉选择统计时间数据栏并展示
    Vue + Element后台项目报错(This relative module was not found)
    Echart图的使用技巧,配置相关样式与属性
    7种方法实现数组去重
  • 原文地址:https://www.cnblogs.com/hehehaha/p/6332118.html
Copyright © 2011-2022 走看看