g ++:内部编译器错误:分段错误(程序cc1plus) - 我从哪里开始?

时间:2017-05-31 13:33:47

标签: c++ makefile g++ ubuntu-14.04 ubuntu-16.04

我正在将 Ubuntu 14.04 上编译的代码移植到 16.04 。我克隆了我的git repo,安装了依赖项并尝试了通常的make命令,很快我点击g++: internal compiler error: Segmentation fault (program cc1plus) ......但我不知道从哪里开始诊断并解决这个问题。

我将尽可能多地分享,看看是否有人可以指导我完成决议。

Ubuntu的

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

克++

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

$ python --version
Python 2.7.12

一些环境变量

PYTHON       /usr/bin/python2.7
ARCH         x86_64
OS           Linux
VERSION      4.4.071generic
PLATFORM     linux2
HOSTNAME     deploy
USER         myUser
WUSS_BUILD   NO
CCVER        gcc
PYLIBDIR     build.x86_64-linux2
LIBDIR       build.x86_64-linux2
BINDIR       build.x86_64-linux2
ODIR         build.x86_64-linux2-gcc
STATICLIBDIR build-static.x86_64-linux2

错误

make命令导致

+++ Compile mycore/boost_json.cc to build.x86_64-linux2-gcc
g++: internal compiler error: Segmentation fault (program cc1plus)   <===
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
mk/makelib2.inc:48: recipe for target 'build.x86_64-linux2-gcc/mycore/boost_json.o' failed
make[1]: *** [build.x86_64-linux2-gcc/mycore/boost_json.o] Error 4
Makefile:152: recipe for target 'make.stage1c' failed
make: *** [make.stage1c] Error 2

错误消息似乎指向g++编译器错误(?)

makelib2.inc:48

$(ODIR)/%.o : %.c
        @mkdir -p $(dir $@)
        @echo "+++ Compile $< to $(ODIR)"
        @$(CC) -MMD -MP -MF $(@:.o=.d) -c -I$(ODIR) $(CFLAGS) $(CFLAGS_$*) -o $@ $<

我意识到要制定一个能够获得适当帮助的正确问题将非常困难。所以请耐心等待,并随意建议添加任何可能有用的东西。不幸的是,我无法分享代码。

更新

尝试将g++升级到更新版本。关注this thread

HERE how to install g++ 7 on Ubuntu

HERE how to install gcc 6 on Ubuntu

2 个答案:

答案 0 :(得分:3)

按照你的指示行事:

  

submit a full bug report,如果合适,请使用预处理来源。

答案 1 :(得分:2)

我如何解决g++分段错误问题

this thread启发

我在 Ubuntu 16.04

上执行了以下操作
   sudo apt-get install build-essential software-properties-common -y
   sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y 
   sudo apt-get update
   sudo apt-get install gcc-snapshot -y 

g++5.4.0增加到5.4.1以解决分段错误问题之后

$ g++ --version
g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904