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
  • 相关阅读:
    电脑出现的问题以及解决方法
    [2] 立方体(Box)图形的生成算法
    [1] 平面(Plane)图形的生成算法
    [0] 各类图形的数据大小获得
    3D几何图形的生成算法
    3D几何图形生成的DEMO
    花了两天时间为我的引擎实现了性能分析的界面显示
    游戏:贪吃虫(GreedyMaggot)
    相声段子:求爱总动员
    三维体数据分割算法
  • 原文地址:https://www.cnblogs.com/hehehaha/p/6332118.html
Copyright © 2011-2022 走看看