我有一个没有 root 访问权限的系统,但我需要安装当前版本的 GCC (4.7.2)。
该系统正在运行 Linux 2.6.18 的 x86_64 版本,并且已经有 GCC 4.1(没有 C++ 支持,尽管 --version 说它是用它构建的)。
编辑5:此时,下面的步骤只是我尝试过的一组操作。从那时起我已经开始清洁几次了。我正在寻找某人详细说明我需要使用所有所需开关进行所有操作的确切顺序。
这是我到目前为止经历过的过程(其中 ROOT 是我的主目录中的一个文件夹)
make-3.82>./configure --prefix=$ROOT && make && make install && hash -r
binutils-2.23>./configure --prefix=$ROOT && make && make install
autoconf-2.69>./configure --prefix=$ROOT && make && make install
automake-1.9>./configure --prefix=$ROOT && make && make install
flex-2.5.37>./configure --prefix=$ROOT && make && make install
libunwind-1.1>./configure --prefix=$ROOT && make && make install
gcc-4.7.2-scratch>../gcc-4.7.2/configure --prefix=$ROOT \
--disable-multilib --disable-nls --enable-languages=c,c++ \
&& make && make install && hash -r
ncurses-5.9>./configure --prefix=$ROOT && make && make install
texinfo-4.13>./configure --prefix=$ROOT && make && make install
glibc-2.14-scratch>touch $ROOT/etc/ld.so.conf
使用以下补丁修补了 glibchttp://sourceforge.net/apps/trac/unattended/wiki/ModifyingTheBootDisk#PatchGLibc http://sourceforge.net/apps/trac/unattended/wiki/ModifyingTheBootDisk#PatchGLibc(更正 2.14 的行号)
glibc-2.14-scratch>../glibc-2.14/configure --prefix=$ROOT \
--with-headers=$3_3_4_HEADERS && make && make install
我添加的标志是为了摆脱undefined reference to '__isoc99_sscanf'
。我不知道修复该问题实际上需要什么标志组合,但它解决了这些标志的问题。
gcc-4.7.2-scratch2>../gcc-4.7.2/configure --prefix=$ROOT \
--disable-multilib --disable-nls --enable-languages=c,c++ \
CPPFLAGS="-I$ROOT/include" CFLAGS="-g -O2 -lc" \
CXXFLAGS="-g -O2 -lc" LDFLAGS="-L$ROOT/lib \
-L$ROOT/lib64" && make && make install
现在我在 GCC 构建期间收到此错误:
build/genmddeps ../../gcc-4.7.2/gcc/config/i386/i386.md > tmp-mddeps
build/genmddeps: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by build/genmddeps)
该错误是有道理的,因为 /lib64 中的 libc 是版本 2.5,但我不知道如何让 GCC 使用我构建的安装到 $ROOT/lib 的 libc。
编辑1:添加 -rpath 没有帮助,但我将 lib 目录添加到 LD_RUN_PATH 和 LD_LIBRARY_PATH 中。有了这些设置,我无法运行任何东西,因为我收到了错误[program_name]: error while loading shared libraries: /home/mrambiguous/root/lib/libc.so.6: ELF file OS ABI invalid
另一个需要注意的奇怪的事情是,当我尝试 -rpath 建议时,我开始从 GCC 收到有关无法识别的命令行选项(例如 -V)的错误。我必须将其设置为使用系统的 GCC 4.1。现在我不确定我的第一个 GCC 版本是否以某种方式损坏了,或者它是否曾经被使用过。
编辑 2:我刚刚在 vim 中打开 libc.so.6,看看是否能以纯文本形式找到有关 ABI 的任何内容,其中包含版权信息。libc ABIs: UNIQUE IFUNC
它还确认 GCC 4.7.2 正在同一文本块中运行。Compiled by GNU CC version 4.7.2
编辑 3:删除 $ROOT,重新安装所有内容,同样的问题是不将 -V 和 -qversion 识别为有效选项。
编辑 4:我尝试使用编辑 ELF 标头brandelf -t SVR4 libc.so.6
,但这只会给我一个新的错误unexpected PLT reloc type 0x25