首先安装cmake
1、下载cmake源码,wget https://cmake.org/files/v3.11/cmake-3.11.0-rc4.tar.gz
2、解压tar -zvxf cmake-3.11.0-rc4.tar.gz
3、进入目录cd cmake-3.11.0-rc4/,执行命令./bootstrap
4、编译安装,make;make install
注意:这里执行make install时需要使用 sudo ,否则会报错
CMake Error at cmake_install.cmake:41 (file):
file cannot create directory: /usr/local/doc/cmake-3.11. Maybe need
administrative privileges.
Makefile:73: recipe for target 'install' failed
make: *** [install] Error 1
测试cmake是否安装成功,使用 cmake --help命令,出现
表示安装成功
然后安装Boost
这里是通过命令 wget安装如下:
1. 解压编译
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar zxvf boost_1_64_0.tar.gz
cd boost_1_64_0/
./bootstrap.sh --with-libraries=all --with-toolset=gcc
"--with-libraries:指定可以编译哪些boost库,all表示全部编译"
"--with-toolset:指定编译时使用哪种编译器,指定gcc的版本,如--with-toolset=gcc-x."
成功会有:
......
......
......
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html
2. 编译
./b2 toolset=gcc(如果出现g++找不到的问题,请尝试:yum install gcc-c++)
成功会有(预计十几分钟):
...failed updating 60 targets...
...skipped 21 targets...
...updated 663 targets...
3. 安装
./b2 install --prefix=/usr
"--prefix=/usr用来指定boost的安装目录,不加此参数的话默认的头文件在/usr/local/include/boost目录下,库文件在/usr/local/lib/目录下。这里把安装目录指定为--prefix=/usr则boost会直接安装到系统头文件目录和库文件目录下,可以省略配置环境变量。"
接着安装setuptools
1.wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
2.tar -zxvf setuptools-19.6.tar.gz
3、进入setuptools-19.6编译安装
cd setuptools-19.6.tar.gz
python3 setup.py build
python3 setup.py install
这里要注意权限问题,使用root用户,或者将相关文件权限改为777
最后下载dlib
官网:http://dlib.net/ml.html
点击下载到本地:
解压
tar -jxvf dlib-19.13.tar.bz2
cd dlib-19.13/
然后直接:sudo python3 setup.py install(我这里是安装的是python3),如果前面boost、cmake都是ok了的,那么这步是没问题的,如果不能成功交流交流!
在执行
sudo python3 setup.py install
时遇到了很多问题,在这里记录一下
①在编译到83%时报错 h:111:20: fatal error: Python.h: No such file or directory compilation termi
这样的报错。因为这些库使用了c扩展,需要编译,然后又找不到头文件和静态库导致的。编译这些c库需要的依赖库由python dev
提供,安装即可:
使用aptitude进行安装:
- 1.安装 aptitude
sudo apt-get install aptitude
- 2.然后用aptitude安装python-dev
sudo aptitude install python3-dev
这里要注意使用ubuntu自带的源,不要使用阿里的,否则会出错
② 在编译到96%时报错 c : internal compiler error: Killed (program cc1plus)
经查,是内存不够导致的,我将虚拟机内存调到了3GB后,问题得到解决,最后
dlib 安装成功!!!!!!!!!!