原因在于PyClass_Type是py2的,而不是py3的,所以我们要建立一个纯净的没有PyClass_Type的py3
卸载boost
cd /usr/local/include
rm -rf boost
cd /usr/local/lib
rm -rf *boost*
解压安装包,cd进去
$ ./bootstrap.sh --with-python=/usr/bin/python2
...
Detecting Python version... 2.7
$ ./b2 --with-python --buildid=2 # produces libboost_python-2.so
$ ./bootstrap.sh --with-python=/usr/bin/python3 --with-python-root=/usr
...
Detecting Python version... 3.3
$ ./b2 --with-python --buildid=3noclean # produces libboost_python-3noclean.so
$ ./b2 --with-python --clean
$ ./b2 --with-python --buildid=3 # produces libboost_python-3.so
$ nm -D stage/lib/libboost_python-2.so | grep PyClass_Type
U PyClass_Type
$ nm -D stage/lib/libboost_python3-3noclean.so | grep PyClass_Type
U PyClass_Type
$ nm -D stage/lib/libboost_python3-3.so | grep PyClass_Type
安装到系统默认目录
sudo ./b2 install
参考:
https://stackoverflow.com/questions/25188861/libboost-python3-so-1-56-0-undefined-symbol-pyclass-type/25355855
https://blog.csdn.net/timothyzh/article/details/8758169