机器学习mxnet mac下编译问题

来源:互联网 发布:moment.js 计算时间差 编辑:程序博客网 时间:2024/06/06 00:05

机器学习库mxnet,这个库是c++编写的,需要先编译再使用,步骤稍微多些

1.下载代码先

git clone --recursive https://github.com/dmlc/mxnet

2.依赖库编译

brew update
brew tap homebrew/science
brew install opencv
brew install openblas

3.配置文件修改

cd mxnet/make 修改config.mak

USE_BLAS = apple 修改为USE_BLAS = openblas

编译选项修改

# the additional link flags you want to add
ADD_LDFLAGS += -L/usr/local/opt/openblas/lib
# the additional compile flags you want to add
ADD_CFLAGS += -I/usr/local/opt/openblas/include

4.编译

make -j4 编译,如果没有错误就恭喜了,后面就可以直接使用这个库了

我遇到的错误是

Undefined symbols for architecture x86_64:

  "cv::imencode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)", referenced from:

      _main in ccth9FpM.o

ld: symbol(s) not found for architecture x86_64

collect2: error: ld returned 1 exit status

make: *** [bin/im2rec] Error 1

xxx.o每次都不一样,这个其实就是opencv依赖库没有装好,下面2种解决办法:

(1)config.mk  USE_OPENCV = 1改为USE_OPENCV = 0

(2)重装opencv库