gcc5.4.0 编译时的错误汇总

在使用高版本的gcc编译gcc5.4.0时会出现的所有错误。

1、报错:configure: error: in `/usr/local/src/gcc-5.4.0/build’:

解决:缺少gcc需要先安装一个任意gcc版本

2、报错:dereferencing pointer to incomplete type ‘struct ucontext’

解决:./md-unwind-support.h 将61行左右struct ucontext * uc_ = context->cfa

改成 struct ucontext_t * uc_ = context->cfa

3、configure: error: cannot find neither zip nor jar, cannot continue
解决:install zip

4、sanitizer_platform_limits_posix.cc:146:23: fatal error: sys/ustat.h: No such file or directory
注释掉 #include 这行内容(158 行左右)
接着在 250 行左右修改 unsigned struct_ustat_sz = sizeof(struct ustat); 语句,改为如下内容:

  // Use pre-computed size of struct ustat to avoid  which
  // has been removed from glibc 2.28.
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
  || defined(__x86_64__)
#define SIZEOF_STRUCT_USTAT 32
#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
  || defined(__powerpc__) || defined(__s390__)
#define SIZEOF_STRUCT_USTAT 20
#else
#error Unknown size of struct ustat
#endif
  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;

5、 报错:/sanitizer_stoptheworld_linux_libcdep.cc:237:22:

error: aggregate ‘sigaltstack handler_stack’ has incomplete type and cannot be defined struct sigaltstack handler_stack;

解决:将/sanitizer_stoptheworld_linux_libcdep.cc中第237行

struct sigaltstack handler_stack;

修改为:stack_t handler_stack;

将第二行注释

struct link_map;  // Opaque type returned by dlopen().

struct sigaltstack;                 

6、./include/java-signal.h:32:26: error: invalid use of incomplete type ‘struct _Jv_catch_fpe(int, siginfo_t*, void*)::ucontext’ gregset_t &_gregs = _uc->uc_mcontext.gregs;
停止声明非标准名称struct ucontext,现在只使用
POSIX要求的ucontext_t类型定义。
将struct ucontext改为ucontext_t

7、…/…/…/./libsanitizer/sanitizer_common/sanitizer_internal_defs.h:272:72: error: size of array ‘assertion_failed__1086’ is negative

使用sed -e '1086 s|^|//|' -i ./libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
这里的1086可能是其他数字,可根据情况修改命令

8、 报错:……//tsan_platform_linux.cc

res_state *statp = (__res_state*)state;

修改为:

struct __res_state *statp = (struct __res_state*)state;

9、 报错:……// asan_linux.cc

解决:在asan_linux.cc中添加头文件#include 即可

10、手动安装gmp、mpc、mpfr

下载gcc5.4.0,解压后修改文件夹为gcc-build-5.4.0,然后新建dependence文件夹,解压gmp、mpc、mpfr到dependence,然后安装./configure、make、makeinstall

http://www.netgull.com/gcc/releases/gcc-4.5.0/
https://ftp.gnu.org/pub/gnu/gmp/
https://ftp.gnu.org/gnu/mpfr/
https://mirrors.sjtug.sjtu.edu.cn/gnu

11、安装编译时需要使用的命令

./configure --prefix=/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2 --with-gmp=/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2

./configure --prefix=/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2 --with-gmp=/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2

./configure --prefix=/home/test/gcc-build-5.4.0/dependence/mpc-0.8.1 --with-gmp=/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2 --with-mpfr=/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2

./configure --prefix=/home/test/gcc-build-5.4.0 --disable-multilib --with-gmp=/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2 --with-mpfr=/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2 --with-mpc=/home/test/gcc-build-5.4.0/dependence/mpc-0.8.1

12、使用时需要使用的命令

export PATH=/home/test/gcc-build-5.4.0/bin:$PATH
export LD_LIBRARY_PATH=/home/test/gcc-build-5.4.0/lib64:/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2/lib:/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2/lib:/home/test/gcc-build-5.4.0/dependence/mpc-0.8.1/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/test/gcc-build-5.4.0/dependence/gmp-4.3.2/lib:$LD_LIBRARY_PATH 
export LD_LIBRARY_PATH=/home/test/gcc-build-5.4.0/dependence/mpfr-2.4.2/lib:$LD_LIBRARY_PATH 
export LD_LIBRARY_PATH=/home/test/gcc-build-5.4.0/dependence/mpc-0.8.1//lib:$LD_LIBRARY_PATH 
export MANPATH=/home/test/gcc-build-5.4.0/share/man:$MANPATH

你可能感兴趣的:(C语言,linux,运维,服务器)