编译 gcc 4.8.5
Compiling gcc 4.8.5
我正在尝试在 Red Hat 6 下编译 gcc 4.8.5。这是我的程序:
tar -xvzf archive.tar.gz
cd gcc-4.8.5
./configure --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gcc4.8.5
make
然后我得到以下错误:
make all-am
make[4]: Entering directory `/app/gfortran_build/gcc-4.8.5/host-x86_64-unknown-linux-gnu/lto-plugin'
/bin/sh ./libtool --tag=CC --tag=disable-static --mode=link gcc -Wall -g -module -bindir /opt/gcc4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5 -o
liblto_plugin.la -rpath /opt/gcc4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5 lto-plugin.lo -Wc,../libiberty/pic/libiberty.a
libtool: link: gcc -shared .libs/lto-plugin.o ../libiberty/pic/libiberty.a -Wl,-soname -Wl,liblto_plugin.so.0 -o .libs/liblto_plugin.so.0.0.0
/usr/bin/ld: ../libiberty/pic/libiberty.a(simple-object-coff.o): relocation R_X86_64_PC32 against undefined symbol `simple_object_set_big_16' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
我已经阅读了有关 CFLAGS
的内容,但我无法让它发挥作用。
亲切的问候
GCC 已记录需要在其源代码树外部构建;请参阅 configuring chapter of its installation 文档:
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree. This is how we generally build GCC; building where srcdir == objdir
should still work, but doesn’t get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.
因此您需要根据该规则构建它。因此你的 GCC 构建:
cd gcc-4.8.5
#wrong code from the original question! Don't use that
./configure --enable-bootstrap --enable-shared \
--enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gcc4.8.5
错误;我至少会推荐:
cd gcc-4.8.5
mkdir ../_BuildGCC
cd ../_BuildGCC
../gcc-4.8.5/configure --enable-bootstrap --enable-shared \
--enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gnu \
--program-suffix=-mine
然后,在整个构建之后,可能与
make -j4
之后是一些 mkdir /opt/gnu
具有适当用户和许可的人,然后(在同一个 _BuildGCC
中)
make install DESTDIR=/tmp/gccinst
,最后 cp -vr /tmp/gccinst/opt/gnu /opt/gnu
成为 运行 适当的(可能是 root....,也许 cp -va
)
然后您将 /opt/gnu/bin/
添加到您的 PATH
variable,然后您将使用 gcc-mine
来编译您的代码。
顺便说一句,GCC 与 C 程序兼容,因为 ABI don't change. And GCC 4.8 is obsolete and unsupported. You'll better compile from source the supported versions (listed on gcc.gnu.org; in January 2018, GCC 7.2 & GCC 6.4)
也许您的特定 Redhat 系统需要 additional/specific CFLAGS
附加 到您的 configure
命令中。您可以询问您的 Redhat 支持,或者尝试在 ../gcc-4.8.5/configure
命令的末尾附加 CFLAGS=-fPIE
或 CFLAGS=-fPIC
。
最后,您可能会在 gcc-help@gcc.gnu.org
上获得此类帮助,但您最好尝试使用最新的 GCC。很少有 GCC 成员记得 4.8 ....
如果您确实确切地 GCC 4.8(但我对此表示怀疑),如果需要,您可以购买昂贵的支持(例如来自 RedHat 或 AdaCore 的人)。
Google 我发现 Installing gcc 4.8 and Linuxbrew on CentOS 6
它适用于以下各项:
../gcc-4.8.5/configure CC="/opt/gcc4.5/bin/gcc" --prefix=/opt/gcc4.8.5 --enable-languages=c,c++,fortran --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object
有趣的部分是 CC=...
安装的gcc版本是4.4。使用此版本,编译失败。
亲切的问候
我正在尝试在 Red Hat 6 下编译 gcc 4.8.5。这是我的程序:
tar -xvzf archive.tar.gz
cd gcc-4.8.5
./configure --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gcc4.8.5
make
然后我得到以下错误:
make all-am
make[4]: Entering directory `/app/gfortran_build/gcc-4.8.5/host-x86_64-unknown-linux-gnu/lto-plugin'
/bin/sh ./libtool --tag=CC --tag=disable-static --mode=link gcc -Wall -g -module -bindir /opt/gcc4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5 -o
liblto_plugin.la -rpath /opt/gcc4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5 lto-plugin.lo -Wc,../libiberty/pic/libiberty.a
libtool: link: gcc -shared .libs/lto-plugin.o ../libiberty/pic/libiberty.a -Wl,-soname -Wl,liblto_plugin.so.0 -o .libs/liblto_plugin.so.0.0.0
/usr/bin/ld: ../libiberty/pic/libiberty.a(simple-object-coff.o): relocation R_X86_64_PC32 against undefined symbol `simple_object_set_big_16' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
我已经阅读了有关 CFLAGS
的内容,但我无法让它发挥作用。
亲切的问候
GCC 已记录需要在其源代码树外部构建;请参阅 configuring chapter of its installation 文档:
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree. This is how we generally build GCC; building where
srcdir == objdir
should still work, but doesn’t get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.
因此您需要根据该规则构建它。因此你的 GCC 构建:
cd gcc-4.8.5
#wrong code from the original question! Don't use that
./configure --enable-bootstrap --enable-shared \
--enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gcc4.8.5
错误;我至少会推荐:
cd gcc-4.8.5
mkdir ../_BuildGCC
cd ../_BuildGCC
../gcc-4.8.5/configure --enable-bootstrap --enable-shared \
--enable-threads=posix --enable-checking=release \
--with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-languages=fortran,c --prefix=/opt/gnu \
--program-suffix=-mine
然后,在整个构建之后,可能与
make -j4
之后是一些 mkdir /opt/gnu
具有适当用户和许可的人,然后(在同一个 _BuildGCC
中)
make install DESTDIR=/tmp/gccinst
,最后 cp -vr /tmp/gccinst/opt/gnu /opt/gnu
成为 运行 适当的(可能是 root....,也许 cp -va
)
然后您将 /opt/gnu/bin/
添加到您的 PATH
variable,然后您将使用 gcc-mine
来编译您的代码。
顺便说一句,GCC 与 C 程序兼容,因为 ABI don't change. And GCC 4.8 is obsolete and unsupported. You'll better compile from source the supported versions (listed on gcc.gnu.org; in January 2018, GCC 7.2 & GCC 6.4)
也许您的特定 Redhat 系统需要 additional/specific CFLAGS
附加 到您的 configure
命令中。您可以询问您的 Redhat 支持,或者尝试在 ../gcc-4.8.5/configure
命令的末尾附加 CFLAGS=-fPIE
或 CFLAGS=-fPIC
。
最后,您可能会在 gcc-help@gcc.gnu.org
上获得此类帮助,但您最好尝试使用最新的 GCC。很少有 GCC 成员记得 4.8 ....
如果您确实确切地 GCC 4.8(但我对此表示怀疑),如果需要,您可以购买昂贵的支持(例如来自 RedHat 或 AdaCore 的人)。
Google 我发现 Installing gcc 4.8 and Linuxbrew on CentOS 6
它适用于以下各项:
../gcc-4.8.5/configure CC="/opt/gcc4.5/bin/gcc" --prefix=/opt/gcc4.8.5 --enable-languages=c,c++,fortran --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object
有趣的部分是 CC=...
安装的gcc版本是4.4。使用此版本,编译失败。
亲切的问候