You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16.04编译Nginx 1.13.8时libpcre报错的解决方法咨询

Fixing ".rodata can not be used when making a shared object" Error When Compiling Nginx 1.13.8 on Ubuntu 16.04.3 LTS

Hey there, let's work through this compilation error you're hitting with Nginx 1.13.8 on Ubuntu 16.04.3. That .rodata error usually pops up when there's a mismatch between position-independent code (PIC/PIE) settings during compilation, especially with the PCRE library. Since you want to fix this solely via ./configure parameters, here are the exact steps to try:

1. Add PCRE-Specific Compile Flags to Configure

The core fix is to force the PCRE library compilation to use -fPIC instead of -fPIE by passing this flag directly through Nginx's configure script. Add the following parameter to your existing ./configure command:

--with-pcre-opt="-fPIC"

Example Full Configure Command

If your original configure command looked something like this:

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-threads --with-stream --with-stream_ssl_module

Update it to include the PCRE flag:

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-threads --with-stream --with-stream_ssl_module --with-pcre-opt="-fPIC"

2. If the Error Persists: Compile a Custom PCRE Library

If the above flag doesn't resolve the issue, it might be due to compatibility problems with Ubuntu 16.04's default PCRE library. In this case, tell Nginx to compile its own PCRE instance by downloading the latest stable PCRE source (e.g., 8.45), extracting it, and adding this parameter to your configure command:

--with-pcre=/path/to/your/extracted/pcre-source

Combine it with the earlier flag for a full fix:

./configure [your-existing-flags] --with-pcre=/path/to/pcre-source --with-pcre-opt="-fPIC"

3. Pre-Compilation Cleanup

Before re-running make, make sure to clear any leftover build files from previous attempts:

make clean

Key Notes

  • Ensure you have the PCRE development packages installed first with: sudo apt-get install libpcre3-dev
  • The --with-pcre-opt="-fPIC" flag overrides Nginx's default PCRE compile options, forcing position-independent code that's compatible with shared object requirements.

内容的提问来源于stack exchange,提问作者Katai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:29:51