Nginx1.25 编译最新ngx_brotli问题记录

Nginx1.25 编译最新ngx_brotli问题记录

因为Nginx在1.25版本终于合并了HTTP/3 QUIC相关的内容,于是我打算升级博客目前所用的Nginx以支持HTTP/3协议

因为博客一直有使用ngx_brotli,所以这次安装时也拉取了最新的ngx_brotli模块,但在实际操作过程中发现之前的步骤似乎失效了,编译过程中会反复的出现同一个报错

-L/usr/local/lib -ljemalloc -Wl,-E -ldl -lpthread -lcrypt -L/usr/local/lib -lluajit-5.1 -lm -ldl -L/www/server/ngx_brotli/deps/brotli/c/../out -lbrotlienc -lbrotlicommon -lm pcre-8.43/.libs/libpcre.a /www/server/nginx/src/openssl/.openssl/lib/libssl.a /www/server/nginx/src/openssl/.openssl/lib/libcrypto.a -ldl -lpthread -lz -lxml2 -lxslt -lexslt -lgd \
-Wl,-E
/bin/ld: cannot find -lbrotlienc
/bin/ld: cannot find -lbrotlicommon
collect2: error: ld returned 1 exit status
make[1]: *** [objs/Makefile:440: objs/nginx] Error 1
make[1]: Leaving directory '/www/server/nginx/src'
make: *** [Makefile:10: build] Error 2

无奈之下去Google了相关信息,发现在23年9月有个issue和我一个报错

然后他给出的解决办法看起来相当的复杂,但仔细看项目首页的安装步骤,似乎只是新主线版本更改了安装步骤

那么新版本的安装过程如下

git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli
cd ngx_brotli/deps/brotli
mkdir out && cd out
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..
cmake --build . --config Release --target brotlienc
cd ../../../..

gcc编译器必须大于10.2.1,低于或等于此版本在编译过程中会循环卡在以下的警告中

warning: 'memcpy' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]

相关的issue可参考此问题:Warning: ‘memcpy’ specified bound between …. exceeds maximum object size · Issue #18738 · vlang/v (github.com)

剩下的步骤就和之前版本一样了,正常指定ngx_brotli目录即可

./configure --add-module=/path/to/ngx_brotli
make && make install

参考资料

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发
头像
说点什么?
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容