码迷,mamicode.com
首页 > 其他好文 > 详细

can not be used when making a PIE object; recompile with -fPIC

时间:2020-09-18 01:07:32      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:ram   sbin   split   conf   tables   record   highlight   orm   sse   

技术图片
 1 root@data-server /m/o/tengine# ./configure --prefix=/usr/local/nginx --with-pcre --with-stream  --with-http_perl_module  2                                --with-http_mp4_module  3                                --with-http_flv_module  4                                --with-http_gunzip_module  5                                --with-http_ssl_module  6                                --with-http_realip_module  7                                --with-file-aio  8                                --group=nginx  9                                --user=USER 10                                --conf-path=/etc/nginx/nginx.conf 11                                --sbin-path=/usr/local/sbin/nginx  && make && make install
12 ...
13 /usr/bin/ld: objs/src/stream/ngx_stream_map_module.o: relocation R_X86_64_32 against `.rodata.str1.1 can not be used when making a PIE object; recompile with -fPIC
14 /usr/bin/ld: objs/src/stream/ngx_stream_split_clients_module.o: relocation R_X86_64_32 against `.rodata.str1.1 can not be used when making a PIE object; recompile with -fPIC
15 /usr/bin/ld: objs/src/stream/ngx_stream_return_module.o: relocation R_X86_64_32 against `.rodata.str1.1 can not be used when making a PIE object; recompile with -fPIC
16 /usr/bin/ld: objs/src/stream/ngx_stream_upstream_hash_module.o: relocation R_X86_64_32 against `.rodata.str1.8 can not be used when making a PIE object; recompile with -fPIC
17 /usr/bin/ld: objs/src/stream/ngx_stream_upstream_least_conn_module.o: relocation R_X86_64_32 against `.rodata.str1.8 can not be used when making a PIE object; recompile with -fPIC
18 /usr/bin/ld: objs/src/stream/ngx_stream_upstream_random_module.o: relocation R_X86_64_32 against `.rodata.str1.8 can not be used when making a PIE object; recompile with -fPIC
19 /usr/bin/ld: objs/src/stream/ngx_stream_upstream_zone_module.o: relocation R_X86_64_32 against symbol `ngx_stream_upstream_module can not be used when making a PIE object; recompile with -fPIC
20 /usr/bin/ld: 最后的链结失败: 输出不可表示的节
21 collect2: 错误:ld 返回 1
22 make[1]: *** [objs/Makefile:290:objs/nginx] 错误 1
23 make[1]: 离开目录"/mdata/opt/tengine"
24 make: *** [Makefile:8:build] 错误 2
View Code

在编译nginx的时候遇见上面的错误,各种折腾,都没有解决,最终终于按照同事的思路,找到解决方案了:

  解决办法:

修改编译完的文件:objs/Makefile

在所有包含CFLAGS参数的后面添加 -fPIC,最终改完结果如下:

技术图片
1 root@data-server /m/o/tengine# head objs/Makefile | grep CFLAGS
2 CFLAGS =  -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
3 NGX_PERL_CFLAGS = -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE
4 NGX_PM_CFLAGS = -fPIC -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE
View Code

 

can not be used when making a PIE object; recompile with -fPIC

标签:ram   sbin   split   conf   tables   record   highlight   orm   sse   

原文地址:https://www.cnblogs.com/petersonx/p/13666735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!