使用ld编译错误:__ stack_chk_guard @@ GLIBC_2.17

时间:2016-08-12 19:54:00

标签: c++ linux gcc g++ odroid

我正在编译运行Ubuntu 16.04.1的odroidC2板(armv8-64bit)上的一些文件,我收到以下错误:

odroid@odroid64:~/flext-master/tutorial/simple1$ g++ -fPIC -L/usr/lib -pthread -shared -Wl,-S -L/usr/local/src/pd/bin -L/usr/local/lib -o pd-linux/release-single/simple1.pd_linux   pd-linux/release-single/main.opp  -lflext-pd_s 
/usr/bin/ld: /usr/local/lib/libflext-pd_s.a(libflext_pd_s_la-flxlet.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libflext-pd_s.a(libflext_pd_s_la-flxlet.o)(.text+0x344): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

如您所见,-fPIC选项存在。所以我不明白为什么编译器建议“使用-fPIC重新编译”。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

问题不在你使用pd-linux/release-single/main.opp编译的-fPIC(BTW,也许是.cpp?)中,而是在包含对象{{1}的libflext-pd_s.a存档中它不是用libflext_pd_s_la-flxlet.o编译的,所以你需要正确地重新编译flext库。