编译gcc-4.7.2时出错 [英] Error Compiling gcc-4.7.2

查看:198
本文介绍了编译gcc-4.7.2时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



首先我运行contrib / download_prerequisites下载所需的软件包然后按照LFS上的说明 http://www.linuxfromscratch.org/blfs/ view / svn / general / gcc.html



运行 make bootstrap 时,出现错误消息:

 从../../gcc-4.7.2/gcc/c-lang.c包含的文件中: 24:0:
../../gcc-4.7.2/gcc/system.h:499:20:错误:'strsignal'的冲突类型
/usr/include/string.h :566:14:注意:之前的'strsignal'声明在这里

我的情况与在这里发布的: http://gcc.gnu.org/ ml / gcc-help / 2011-12 / msg00062.html 。原因也是一样的:gcc发现错误的 config.h ,它应该是当前目录下的那个,但实际上它使用了 gmp 。



我发现原因是,即使命令行指定 -I。在所有其他 -I 选项之前, -I。被忽略,因为它已经在标准搜索中路径。这是我通过运行 gcc -v 获得的消息:

 忽略重复目录。 
,因为它是复制系统目录的非系统目录

这是订单与此问题相关的路径搜索( http://gcc.gnu.org/onlinedocs /cpp/Search-Path.html ):
唯一的例外是默认情况下已经搜索到dir,在这种情况下,该选项将被忽略,并且系统目录的搜索顺序保持不变。



在我的 -I 选项指定的其他路径之前,我可以怎样做gcc搜索当前目录?

产生错误信息的命令是:

  gcc  - c -DIN_GCC_FRONTEND -g -fkeep -inline-functions -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno- variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc ++  -  compat -fno-common -DHAVE_CONFIG_H -I。 -一世。 -I ../../ gcc-4.7.2 / gcc -I ../../ gcc-4.7.2 / gcc /。 -I ../../ gcc-4.7.2 / gcc /../ include -I ../../ gcc-4.7.2 / gcc /../ libcpp / include -I / home / dwang /下载/gcc-build/./gmp -I / home / dwang / Downloads / gcc-4.7.2 / gmp -I / home / dwang / Downloads / gcc-build /./ mpfr -I / home / dwang / Downloads / gcc -4.7.2 / mpfr -I / home / dwang / Downloads / gcc-4.7.2 / mpc / src -I ../../ gcc-4.7.2 / gcc /../ libdecnumber -I ../。 ./gcc-4.7.2/gcc/../libdecnumber/bid -I ../ libdecnumber ../../gcc-4.7.2/gcc/c-lang.c -o c-lang.o 

谢谢。

解决方案

这在我的〜/ .bashrc 中是非常有线的配置问题。我曾经将以下行添加到bashrc中:

  export C_INCLUDE_PATH = / home / dwang / local / include:/ export / scratch / packages / include /:$ C_INCLUDE_PATH 



echo $ C_INCLUDE_PATH 是:

  / home / dwang / local / include:/ export / scratch / packages / include / :

事实证明,如果有一个尾随的在C_INCLUDE_PATH中,然后添加。如果我删除了后面的,一切都很好。



原因记录这里


在所有这些变量中,一个空元素指示编译器搜索其当前工作目录。空元素可以出现在路径的开始或结尾。例如,如果CPATH的值是:/ special / include,则与`-I具有相同的效果。 -I /特/包括。



I'm trying to compile gcc-4.7.2 from source using gcc-4.6.1.

First I run the contrib/download_prerequisites to download the required packages then follow instructions on LFS http://www.linuxfromscratch.org/blfs/view/svn/general/gcc.html

when running make bootstrap, I got the error message:

In file included from ../../gcc-4.7.2/gcc/c-lang.c:24:0:
../../gcc-4.7.2/gcc/system.h:499:20: error: conflicting types for ‘strsignal’
/usr/include/string.h:566:14: note: previous declaration of ‘strsignal’ was here

My situation is the same as the one posted here: http://gcc.gnu.org/ml/gcc-help/2011-12/msg00062.html . The reason is also the same: gcc finds the wrong config.h, which should be the one at the current directory, but actually it uses the one under gmp.

I find the reason is that, even though the command line specify -I. before all other -I options, -I. is ignored because it is already in the standard search path. Here is the message I got via running gcc -v:

ignoring duplicate directory "."
as it is a non-system directory that duplicates a system directory

Here is the order of path searching related to this problem ( http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html ): "The only exception is when dir is already searched by default. In this case, the option is ignored and the search order for system directories remains unchanged."

What can I do to make gcc search the current directory before other paths specified by -I options?

The command that yield the error message is:

gcc -c  -DIN_GCC_FRONTEND -g -fkeep-inline-functions -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.7.2/gcc -I../../gcc-4.7.2/gcc/. -I../../gcc-4.7.2/gcc/../include -I../../gcc-4.7.2/gcc/../libcpp/include -I/home/dwang/Downloads/gcc-build/./gmp -I/home/dwang/Downloads/gcc-4.7.2/gmp -I/home/dwang/Downloads/gcc-build/./mpfr -I/home/dwang/Downloads/gcc-4.7.2/mpfr -I/home/dwang/Downloads/gcc-4.7.2/mpc/src  -I../../gcc-4.7.2/gcc/../libdecnumber -I../../gcc-4.7.2/gcc/../libdecnumber/bid -I../libdecnumber    ../../gcc-4.7.2/gcc/c-lang.c -o c-lang.o

Thanks.

解决方案

This turns out to be a very wired configuration problem in my ~/.bashrc. I used to add the following line to bashrc:

export C_INCLUDE_PATH=/home/dwang/local/include:/export/scratch/packages/include/:$C_INCLUDE_PATH

The output of echo $C_INCLUDE_PATH is:

/home/dwang/local/include:/export/scratch/packages/include/:

It turns out that if there is a trailing : in the C_INCLUDE_PATH, then . is also added. If I remove the trailing :, everything is fine.

The reason is documented here:

In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as `-I. -I/special/include'.

这篇关于编译gcc-4.7.2时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆