gpt4 book ai didi

linux - 构建 glibc 时出现 "can not be used when making a shared object"

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:14:21 65 4
gpt4 key购买 nike

我正在 Debian 9.8 (x64) 上编译 glibc 2.19,但在运行 make 后出现以下错误。如何解决这个问题?

gcc -B/usr/bin/ -nostdlib -nostartfiles -o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/iconv_prog    -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /home/cyril/HME/Multcore_version/AHME/glibc-build/csu/crt1.o /home/cyril/HME/Multcore_version/AHME/glibc-build/csu/crti.o `gcc -B/usr/bin/  --print-file-name=crtbegin.o` /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/iconv_prog.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/iconv_charmap.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/charmap.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/charmap-dir.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/linereader.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/dummy-repertoire.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/simple-hash.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/xstrdup.o /home/cyril/HME/Multcore_version/AHME/glibc-build/iconv/xmalloc.o  -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2 -Wl,-rpath-link=/home/cyril/HME/Multcore_version/AHME/glibc-build:/home/cyril/HME/Multcore_version/AHME/glibc-build/math:/home/cyril/HME/Multcore_version/AHME/glibc-build/elf:/home/cyril/HME/Multcore_version/AHME/glibc-build/dlfcn:/home/cyril/HME/Multcore_version/AHME/glibc-build/nss:/home/cyril/HME/Multcore_version/AHME/glibc-build/nis:/home/cyril/HME/Multcore_version/AHME/glibc-build/rt:/home/cyril/HME/Multcore_version/AHME/glibc-build/resolv:/home/cyril/HME/Multcore_version/AHME/glibc-build/crypt:/home/cyril/HME/Multcore_version/AHME/glibc-build/nptl /home/cyril/HME/Multcore_version/AHME/glibc-build/libc.so.6 /home/cyril/HME/Multcore_version/AHME/glibc-build/libc_nonshared.a -Wl,--as-needed /home/cyril/HME/Multcore_version/AHME/glibc-build/elf/ld.so -Wl,--no-as-needed -lgcc  `gcc -B/usr/bin/  --print-file-name=crtend.o` /home/cyril/HME/Multcore_version/AHME/glibc-build/csu/crtn.o

/usr/bin/ld: /home/cyril/HME/Multcore_version/AHME/glibc-build/csu/crt1.o: relocation R_X86_64_32S against symbol `__libc_csu_fini' can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/6/crtbegin.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object

/usr/bin/ld: final link failed: Nonrepresentable section on output

/usr/bin/ld: /home/cyril/HME/Multcore_version/AHME/glibc-build/csu/crt1.o: relocation R_X86_64_32S against symbol `__libc_csu_fini' can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/6/crtbegin.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object

/usr/bin/ld: final link failed: Nonrepresentable section on output

collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status

最佳答案

您的 GCC 默认配置为生成与位置无关的可执行文件。但是 GLIBC-2.19 的 Makefile 并没有为这样的配置做好准备。

第 1 步:验证 PIE 部分是否为真:

echo "int main() { return 0; }" | gcc -xc - &&
file ./a.out

它应该说“共享库”或“位置无关的可执行文件”。

第 2 步:您可以通过将 -no-pie 添加到 LDFLAGS 来修复构建的 GLIBC-2.19。

关于linux - 构建 glibc 时出现 "can not be used when making a shared object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55514324/

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