SSD: Single Shot MultiBox Detector 是ECCV 2016上发表的目标检测的论文(https://arxiv.org/pdf/1512.02325.pdf),作者在github上公布了代码,地址为https://github.com/weiliu89/caffe/tree/ssd.
但是编译的时候确出现了 Type name declared error
/usr/include/boost/property_tree/detail/json_parser_read.hpp: In constructor ‘boost::property_tree::json_parser::json_grammar ::definition ::definition(const boost::property_tree::json_parser::json_grammar& )’:
/usr/include/boost/property_tree/detail/json_parser_read.hpp:257:264: error: ‘type name’ declared as function returning an array
代码Repository 的Issues中#54 #83等建议使用gcc 5.3或5.4编译caffe,以下是安装GCC5.4和用gcc 5.4编译caffe的过程。
操作系统:Red Hat 4.8.5-11
GCC 版本:gcc 4.8.5
GCC5.4可以从官网下载,也可以从镜像下载,我们这里从清华大学的镜像下载,地址为:
https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
tar -xf gcc-5.4.0.tar.gz
cd gcc-5.4.0
gcc 5.4.0依赖于 gmp, mpc, mpfr 三个库,gcc5.4提供了下载脚本并在编译的时候安装
./contrib/download_prerequisites
./configure --prefix=/home/share/local --enable-languages=c,c++,fortran --disable-multilib
在里/home/share/local是我安装gcc-5.40的路径,可以改成自己路径。
make -j8
make install
编译之后需要将bin的路径加到PATH中,并且将lib64(如果有lib的话也加进去)的路径加到LD_LIBRARY_PATH中
export PATH=/home/share/local/bin:$PATH
export LD_LIBRARY_PATH=/home/share/local/lib64:/home/share/local/lib:$LD_LIBRARY_PATH
protobuf-3.4.1下载地址
tar -xf protobuf-cpp-3.4.1.tar.gz
cd protobuf-3.4.1/
./configure --prefix=/home/share/local
在里/home/share/local是安装路径
make -j8
make install
Boost 1.56.0下载地址https://sourceforge.net/projects/boost/files/boost/1.56.0/boost_1_56_0.tar.bz2/download
tar -jxf boost_1_56_0.tar.bz2
cd boost_1_56_0/
./bootstrap.sh --prefix=/home/share/local
在里/home/share/local是安装路径
./b2 -j8
./b2 install
...failed updating 4 targets...
...skipped 12 targets...
...updated 11322 targets...
gflags-2.2.0 下载地址https://codeload.github.com/gflags/gflags/tar.gz/v2.2.0
tar -xf gflags-2.2.0.tar.gz
cd gflags-2.2.0/
z这里我们使用cmake 配置编译选项,cmake版本是cmake 3.8.2
ccmake .. -DCMAKE_INSTALL_PREFIX=/home/share/local/ -DBUILD_SHARED_LIBS=ON
使用ccmake命令配置时,最开始按c健进行configure, 然后再按一次c键确认configure,然后按g键进行生成Makefile,进行编译。
make -j8
make install
git clone https://github.com/google/glog.git
cd glog/
这里我们仍然使用cmake 配置编译选项,好处是可以很方便地找到我们刚编译的gflags,否则容易和已安装的gflags混淆。
ccmake .. -DCMAKE_INSTALL_PREFIX=/home/share/local/ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=/home/share/local/bin/g++ -DCMAKE_C_COMPILER=/home/share/local/bin/gcc
使用ccmake命令配置时,最开始按c健进行configure, 然后再按一次c键确认configure,然后按g键进行生成Makefile,进行编译。
make -j8
make install
git clone https://github.com/google/leveldb.git
cd leveldb
make -j8
cp -av out-shared/libleveldb.so* /home/share/local/lib/
cp -av include/leveldb /home/share/local/include/
其他依赖库似乎不用重新用gcc 5.4编译,可以使用原来的依赖库,现在我们来编译ssd的代码
git clone https://github.com/weiliu89/caffe.git
cd caffe
git checkout ssd
make -j8