gpt4 book ai didi

编译 glibc :/glibc-2. 7/w/elf/ld.so: 没有那个文件或目录

转载 作者:太空宇宙 更新时间:2023-11-04 08:20:41 43 4
gpt4 key购买 nike

我要在超算中心的目录下安装一个软件,但是sudo,root,连apt-get,yum都不能用...这个软件需要glibc2.7,所以我得手动安装gcc和glibc(因为我无法更改内置 gcc 的路径来查找 glibc)。

gcc 似乎安装成功:

[geosign@node117 ~/binutils/bin]$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /public/home/geosign/software/gcc/configure -prefix=/public/home/geosign/gcc --with-gmp=/public/home/geosign/Gcc --with- mpfr=/public/home/geosign/Gcc --with-mpc=/public/home/geosign/Gcc --with-ppl=/public/home/geosign/ppl --with-cloog=/public/home/geosign/ppl --enable-threads=posix CFLAGS=-I/public/home/geosign/ppl/lib:/public/home/geosign/Gcc/lib CPPFLAGS=-I/public/home/geosign/ppl/lib:/public/home/geosign/Gcc/lib CXXFLAGS=-I/public/home/geosign/ppl/lib:/public/home/geosign/Gcc/lib --enable-languages=c,c++,fortran --disable-multilib

线程模型:posix gcc 版本 4.4.7 (GCC)

但是,当我使用“make”编译glibc时,它显示:

make[3]: Leaving directory `/public/home/geosign/software/glibc/elf'
gcc -B/public/home/geosign/binutils/ -nostdlib -nostartfiles -r -o /public/home/geosign/software/build/glibc/elf/librtld.os '-Wl,-(' /public/home/geosign/software/build/glibc/elf/dl-allobjs.os /public/home/geosign/software/build/glibc/elf/rtld-libc.a -lgcc '-Wl,-)' \
-Wl,-Map,/public/home/geosign/software/build/glibc/elf/librtld.os.map
gcc -B/public/home/geosign/binutils/ -nostdlib -nostartfiles -shared \
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,--verbose 2>&1 | \
LC_ALL=C \
sed -e '/^=========/,/^=========/!d;/^=========/d' \
-e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
> /public/home/geosign/software/build/glibc/elf/ld.so.lds
gcc -B/public/home/geosign/binutils/ -nostdlib -nostartfiles -shared -o /public/home/geosign/software/build/glibc/elf/ld.so \
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \
/public/home/geosign/software/build/glibc/elf/librtld.os -Wl,--version-script=/public/home/geosign/software/build/glibc/ld.map \
-Wl,-soname=ld-linux-x86-64.so.2 -T /public/home/geosign/software/build/glibc/elf/ld.so.lds
/public/home/geosign/software/build/glibc/elf/librtld.os: In function `_dl_start_final':
/public/home/geosign/software/glibc/elf/rtld.c:290: undefined reference to `_begin'
/public/home/geosign/binutils/bin/ld: /public/home/geosign/software/build/glibc/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_begin' can not be used when making a shared object
/public/home/geosign/binutils/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [/public/home/geosign/software/build/glibc/elf/ld.so] Error 1
make[2]: Leaving directory `/public/home/geosign/software/glibc/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/public/home/geosign/software/glibc'
make: *** [all] Error 2

elf的Makefile中的这几句是:

$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
@rm -f $@.lds
$(LINK.o) -nostdlib -nostartfiles -shared $(z-now-$(bind-now)) \
$(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \
LC_ALL=C \
sed -e '/^=========/,/^=========/!d;/^=========/d' \
-e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
> $@.lds
$(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
$(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
$(filter-out $(map-file),$^) $(load-map-file) \
-Wl,-soname=$(rtld-installed-name) -T $@.lds
rm -f $@.lds
readelf -s $@ \
| awk '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'

这是我配置 glibc 的方式:

/public/home/geosign/software/glibc/configure --prefix=/public/home/geosign/glibc  --with-binutils=/public/home/geosign/binutils/ --enable-shared --disable-multilib

ldd ld 显示:

[geosign@node117 ~/binutils/bin]$ ldd ld
linux-vdso.so.1 => (0x00007fff163be000)
libz.so.1 => /lib64/libz.so.1 (0x0000003fd1400000)
libc.so.6 => /lib64/libc.so.6 (0x0000003fd0400000)
/lib64/ld-linux-x86-64.so.2 (0x0000003fd0000000)

非常感谢。我的时间真的很有限,我花了很多天时间。

最佳答案

你的直接问题是:

gcc   -nostdlib -nostartfiles -shared -o -mcmodel=large \
/public/home/geosign/software/glibc-2.7/w/elf/ld.so ...

这告诉 GCC 创建一个名为 -mcmodel=large 的输出文件,而不是预期的输出文件 /public/home/geosign/software/glibc-2.7/w/elf/ld .so.

你没有告诉我们你是如何配置这个 GLIBC 构建的,但我怀疑你在 ./configure 调用的某处使用了 -mcmodel=large 。不要那样做,没有理由在构建 glibc 时使用 -mcmodel=large

关于编译 glibc :/glibc-2. 7/w/elf/ld.so: 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33548833/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com