Monthly Archives: March 2019

Unsupported compiler — pybind11 requires C++11 support!

Today I tried to install dlib on my CentOS 6.7 server using this command:

pip install dlib

There is an error:

Unsupported compiler — pybind11 requires C++11 support!

To fix this issue, we need to replace the C++ compiler in /usr/bin by newer version.

So we have to install newer gcc version and replace the c++ compiler with the newer one.

Firstly, we have to install some additional required packages:

 

sudo yum install svn texinfo-tex flex zip libgcc.i686 glibc-devel.i686

Then find gcc available versions:

svn ls svn://gcc.gnu.org/svn/gcc/tags | grep gcc | grep release

I found that gcc 5.5.0 is okay to fix the error above. So I install gcc 5.5.0

svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_5_1_0_release/

Get source of additional prerequisites:

cd gcc_5_1_0_release/

./contrib/download_prerequisites

 

Building gcc could eat much memory. If your server has less than 2GB RAM, you should create swap file:

 

SWAP=/tmp/swap

dd if=/dev/zero of=$SWAP bs=1M count=500

mkswap $SWAP

sudo swapon $SWAP

Now build gcc:

 

mkdir build

cd build

../configure

make

Building gcc can take 1 hour. So we have to wait now.

After building successfully, we can install it

make install

Now the new c++ compiler is installed in /usr/local/bin/ folder. We need to replace the current c++ compiler with this newer one.

We backup the current compiler first:

 

mv /usr/bin/cc /usr/bin/cc4.4.7

mv /usr/bin/c++ /usr/bin/c++4.4.7

 

Then create symbolic link to the newer version

 

ln -s /usr/local/bin/cc /usr/bin/cc

ln -s /usr/local/bin/c++ /usr/bin/c++

 

Now I can install dlib without the error above:

pip install dlib

After installing, there is an error when importing dlib into python

ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found (required by /usr/local/lib/python2.7/site-packages/dlib/dlib.so

To fix it, we replace the lib in /usr/lib64 with the newer one that we have just built:

mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old

ln -s /usr/local/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6