pip install lanms==1.0.2 g++: error解决方案

问题由来:楼主最近想跑一跑EAST算法的实验,github上面download了一个pytorch的项目,然而需要安装lanms包,于是在我的docker-pytorch自带的ubuntu16.04系统上运行

pip install lanms==1.0.2

结果出Error:

make: Entering directory '/root/File/fsy_SceneTextRec/lanms-1.0.2'
g++ -o lanms/adaptor.so -I include  -std=c++11 -O3 -I/opt/conda/include/python3.6m -I/opt/conda/include/python3.6m  -Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe  -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -flto -DNDEBUG -fwrapv -O3 -Wall -L/opt/conda/lib/python3.6/config-3.6m-x86_64-linux-gnu -L/opt/conda/lib -lpython3.6m -lpthread -ldl  -lutil -lrt -lm  -Xlinker -export-dynamic adaptor.cpp include/clipper/clipper.cpp --shared -fPIC
g++: error: unrecognized command line option '-fno-plt'
Makefile:10: recipe for target 'lanms/adaptor.so' failed
make: *** [lanms/adaptor.so] Error 1
make: Leaving directory '/root/File/fsy_SceneTextRec/lanms-1.0.2'
Traceback (most recent call last):
  File "setup.py", line 28, in <module>
    raise RuntimeError('Cannot compile lanms in the directory: {}'.format(BASE_DIR))
RuntimeError: Cannot compile lanms in the directory: /root/File/fsy_SceneTextRec/lanms-1.0.2

于是楼主在自己的裸机上安装此包,顺利通过(裸机是ubuntu18的)

最后问题出在,ubuntu16.04自带的gcc版本为 gcc version 5.4.0
运行如下指令查看gcc版本

g++ -v

ubuntu18自带的版本是 7.4.0,猜想这才是安装成功的原因,于是我们要做的就是升级gcc的版本!

步骤如下:
1)

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-6

2)

sudo apt install g++-6

3)

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6  

完了以后再查看自己的版本:

gcc -v
g++ -v

结果(成功升级默认的gcc)

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.5.0-2ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.5.0 20181026 (Ubuntu 6.5.0-2ubuntu1~16.04)

最后,安装lanms:

pip install lanms==1.0.2

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&原创文章,转载请注明出处!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

你可能感兴趣的:(各种小bug,pip,lanms,gcc,升级gcc,g++)