c++ - 构建 gcc-4.8.2 时如何理解这些可怕的错误?

标签 c++ linux gcc installation

我正在尝试在远程 Debian 7 系统上安装 gcc-4.8.2 编译器,我没有 root 权限 ,但只有 ssh 访问权限。我发现最简单的方法是从源代码编译编译器。

我正在关注 this short installation manual来自 GCC 网页。

基本上我做了最简单的安装,总结在页面底部:

tar xzf gcc-4.8.2.tar.gz
cd gcc-4.8.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.2/configure --prefix=$HOME/gcc-4.8.2 --enable-languages=c++
make

除了一个小异常(exception),由于防火墙限制,我没有在远程计算机上运行 ./contrib/download_prerequisites 脚本。相反,我在我的本地机器上运行它,然后将整个文件夹压缩回 gcc-4.8.2.tar.gz 并将它scp 到远程机器。在那里我重新创建了指向先决条件库(gmp,...)的符号链接(symbolic link)并运行了 make。几秒钟后,我收到难以置信的错误:

In file included from ./tm.h:19:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:24:
./options.h:4078:2: error: #error too many masks for ix86_isa_flags
In file included from ../../gcc-4.8.2/gcc/tree.h:26:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/statistics.h:25:2: error: #error GATHER_STATISTICS must be defined
In file included from ../../gcc-4.8.2/gcc/system.h:268:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
In file included from ../../gcc-4.8.2/gcc/tree.h:29:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/real.h:103:9: error: #error "REAL_WIDTH > 6 not supported"
In file included from ../../gcc-4.8.2/gcc/c-family/c-common.h:24:0,
                 from ../../gcc-4.8.2/gcc/c/c-tree.h:23,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:26:
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:265:3: error: #error "Cannot find a least-32-bit signed integer type"
In file included from ../../gcc-4.8.2/gcc/c/c-lang.c:22:0:
../../gcc-4.8.2/gcc/system.h:500:34: error: declaration of C function ‘const char* strsignal(int)’ conflicts with
In file included from /usr/include/c++/4.7/cstring:44:0,
                 from ../../gcc-4.8.2/gcc/system.h:205,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
/usr/include/string.h:566:14: error: previous declaration ‘char* strsignal(int)’ here
In file included from ../../gcc-4.8.2/gcc/system.h:645:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
../../gcc-4.8.2/gcc/../include/libiberty.h:110:36: error: new declaration ‘char* basename(const char*)’
In file included from /usr/include/c++/4.7/cstring:44:0,
                 from ../../gcc-4.8.2/gcc/system.h:205,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
/usr/include/string.h:603:28: error: ambiguates old declaration ‘const char* basename(const char*)’
In file included from ../../gcc-4.8.2/gcc/tree.h:27:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/vec.h: In static member function ‘static void va_heap::reserve(vec<T, va_heap, vl_embed>*&, unsigned int, bool)’:
../../gcc-4.8.2/gcc/vec.h:295:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
../../gcc-4.8.2/gcc/vec.h:303:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
../../gcc-4.8.2/gcc/vec.h: In static member function ‘static void va_heap::release(vec<T, va_heap, vl_embed>*&)’:
../../gcc-4.8.2/gcc/vec.h:317:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
In file included from ../../gcc-4.8.2/gcc/tree.h:29:0,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/real.h: At global scope:
../../gcc-4.8.2/gcc/real.h:51:21: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:51:21: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
In file included from ../../gcc-4.8.2/gcc/c-family/c-common.h:24:0,
                 from ../../gcc-4.8.2/gcc/c/c-tree.h:23,
                 from ../../gcc-4.8.2/gcc/c/c-lang.c:26:
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:267:35: error: expected initializer before ‘cppchar_t’
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:268:9: error: ‘CPPCHAR_SIGNED_T’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:777:8: error: ‘cppchar_t’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:788:8: error: ‘cppchar_t’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:966:8: error: ‘cppchar_t’ does not name a type
make[3]: *** [c/c-lang.o] Error 1
make[3]: Leaving directory `/home/mdrozdik/gccbuild/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/mdrozdik/gccbuild'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/mdrozdik/gccbuild'
make: *** [all] Error 2

我正在 Debian 上使用 gcc 4.7.2-5 进行编译。

在本地机器上有 Ubuntu 13.10gcc 4.7.3 并且构建到目前为止似乎很好(仍在运行)。

请问,这些错误可能是什么原因造成的?

编辑:

我检查了 /home/mdrozdik/gccbuild/libcpp/config.log 文件。它很长,但在两个地方有这些错误:

configure:3086: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3097: $? = 4
configure:3086: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3097: $? = 4

但是日志仍然持续了好几页。

最佳答案

我有一个类似的问题 (gcc 4.8.3),这解决了它:g++ 4.7.1 compilation error : conflicting types for ‘strsignal’

解决方案是取消设置一堆 C 编译器标志(CPATH 等)

https://stackoverflow.com/users/1224886/tsbertalan报告这对他有用(这就是我使用的):

unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE

关于c++ - 构建 gcc-4.8.2 时如何理解这些可怕的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21685255/

相关文章:

gcc - 对 libnuma 的 undefined reference

c - "busy wait"与 "sleep"的权衡是什么?

linux - 正确使用 linux inotify - 每次都重新打开?

c++ - 如何在 Windows 上构建 git?

c++ - 对数组值的 static_assert

c - Linux 系统() API

c - 使用 ld 链接已编译的程序集和 C 文件

windows - 如何在 Windows 上将 clang 与 mingw-w64 header 一起使用

C++ pow() 函数在放入函数时会改变行为

c++ - CLANG vs. GNU Compilers Collection - 在 GNU 中编译但在 CLANG 中失败