在OS X 10.11上安装gcc 4.6.1 [英] install gcc 4.6.1 on OS X 10.11
问题描述
我在OS X上安装 gcc 4.6.1
MIT xv6 :
tar xjf gcc-core-4.6.1。 tar.bz2
cd gcc-4.6.1
mkdir build
cd build
../configure --prefix = / usr / local \
--target = i386-jos-elf --disable-werror \
--disable-libssp --disable-libmudflap --with-newlib \
--without-headers --enable-languages = c
make all-gcc
:
gtype-desc.c:8838:18:error:下标值不是数组,
pre>
指针,或向量
sizeof(x_rtl [0]),
~~~~~ ^〜
gtype-desc.c:8957:36:error:下标值不是数组,
指针或向量
sizeof(default_target_libfuncs [0]),
~~~~~~~~~~~~~~~~~~~~~
gtype-desc.c:9041:31:错误:下标值不是数组,
指针或向量
sizeof(default_target_rtl [0]),
~~~~~~ ~~~~~~~~~~~~~ ^〜
gtype-desc.c:9062:31:错误:下标值不是数组,
指针或向量
sizeof (default_target_rtl [0]),
~~~~~~~~~~~~~~~~~~~ ^〜
gtype-desc.c:9069:31:error:subscripted value is不是数组,
指针或向量
sizeof(default_target_rtl [0]),
~~~~~~~~~~~~~~~ $ b gtype-desc.c:9076:31:error:下标值不是数组,
指针或向量
sizeof(default_target_rtl [0]),
~~~~~ ~~~~~~~~~~~~~~ ^〜
68个警告和6个错误生成。
make [1]:*** [gtype-desc.o]错误1
make:*** [all-gcc]错误2
在
中也有错误make install-gcc
,make all-target- libgcc
和make install-target-libgcc
和i386-jos-elf-gcc -v
显示命令未找到
。
我应该如何解决这个问题?是否有替代方法使用命令
i386-jos-elf-gcc
?
gcc --version
配置为:--prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
Apple LLVM版本6.1.0(clang-602.0.49)(基于LLVM 3.6.0svn)
目标:x86_64-apple-darwin15.3.0
线程模型:posix
>
>
gcc
/ usr / bin / gcc
有一个gcc编译器,但是已经重定向到clang?
解决方案[这不是一个完整的答案。 >
首先,请参阅上的解答在OS X 10.11上构建GCC 。
第二:如果您正在尝试构建交叉编译器,强烈建议您首先引导本机版本的gcc。另请参见
INSTALL / build.html
中的构建交叉编译器一节。我用- prefix = / usr / local / gcc
建立了我的地址,所以我的本地gcc最终在/ usr / local / gcc / bin / gcc
。然后,我添加/ usr / local / gcc / bin
到我的$ PATH
,摆脱了/ usr / bin / gcc
和/ usr / bin / g ++
安全。
由于
build.html
指出,你还需要一个交叉汇编器和交叉链接器。因此,您通常需要下载适当版本的binutils,并在之前构建这些,以尝试构建交叉编译器。 (这是我的步骤,我自己,我目前坚持下来,我可能稍后再说。)
最后,如果你发现你的构建失败因为您配置不当,所以您必须使用不同的选项重新运行
configure
,删除整个构建目录并从头开始是更安全的。配置和构建系统有时,但似乎不是100%可靠,检测什么可能需要重建在这种情况下。 (删除和重新开始是令人沮丧的,我同意,但再次,它可以真正节省时间在长期。)I'm installing
gcc 4.6.1
on OS X for MIT xv6:tar xjf gcc-core-4.6.1.tar.bz2 cd gcc-4.6.1 mkdir build cd build ../configure --prefix=/usr/local \ --target=i386-jos-elf --disable-werror \ --disable-libssp --disable-libmudflap --with-newlib \ --without-headers --enable-languages=c
Things are good until
make all-gcc
:gtype-desc.c:8838:18: error: subscripted value is not an array, pointer, or vector sizeof (x_rtl[0]), ~~~~~^~ gtype-desc.c:8957:36: error: subscripted value is not an array, pointer, or vector sizeof (default_target_libfuncs[0]), ~~~~~~~~~~~~~~~~~~~~~~~^~ gtype-desc.c:9041:31: error: subscripted value is not an array, pointer, or vector sizeof (default_target_rtl[0]), ~~~~~~~~~~~~~~~~~~^~ gtype-desc.c:9062:31: error: subscripted value is not an array, pointer, or vector sizeof (default_target_rtl[0]), ~~~~~~~~~~~~~~~~~~^~ gtype-desc.c:9069:31: error: subscripted value is not an array, pointer, or vector sizeof (default_target_rtl[0]), ~~~~~~~~~~~~~~~~~~^~ gtype-desc.c:9076:31: error: subscripted value is not an array, pointer, or vector sizeof (default_target_rtl[0]), ~~~~~~~~~~~~~~~~~~^~ 68 warnings and 6 errors generated. make[1]: *** [gtype-desc.o] Error 1 make: *** [all-gcc] Error 2
There are also errors in
make install-gcc
,make all-target-libgcc
andmake install-target-libgcc
andi386-jos-elf-gcc -v
showcommand not found
.What should I do to fix this? Is there an alternative to use command
i386-jos-elf-gcc
?gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
>
>
which gcc
/usr/bin/gcc
It seems that I do have a gcc compiler, but which has been redirected to clang?
解决方案[This is not a complete answer.]
First, see the answers at Building GCC on OS X 10.11 .
Second: If you're trying to build a cross-compiler, it's highly recommended that you first bootstrap a native version of gcc. See also the section "Building a cross compiler" in
INSTALL/build.html
. I built mine with--prefix=/usr/local/gcc
, so that my native gcc ended up in/usr/local/gcc/bin/gcc
. Then I added/usr/local/gcc/bin
to my$PATH
, and got rid of/usr/bin/gcc
and/usr/bin/g++
to be on the safe side.As
build.html
points out, you're also going to need a "cross-assembler" and "cross-linker". So you generally need to download an appropriate version of binutils, and build those before trying to build your cross-compiler. (This is the step I, myself, am currently stuck on. I may have more to say about this later.)Finally, if you discover that your build is failing because you configured it improperly, such that you have to rerun
configure
with different options, it's safer to delete your entire build directory and start from scratch. The configure and build system sometimes, but it seems not 100% reliably, detects what might need rebuilding in that case. (Deleting and starting over is frustrating, I agree, but again, it can really save time in the long run.)这篇关于在OS X 10.11上安装gcc 4.6.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!