问题描述
我以依赖库的方式修改了Nginx模块....让我们调用需要libx的库。
我对auto/os/linux
进行了修改,使得我可以通过添加类似以下内容来检测libx
是否存在:
+ngx_feature="libx"
+ngx_feature_name="NGX_HAVE_LIBX"
+ngx_feature_run=no
+ngx_feature_incs="#include <libx.h>"
+ngx_feature_path=
+ngx_feature_libs=-lx
+ngx_feature_test="libx_init();"
+. auto/feature
然后,在模块代码中,我#if
进行NGX_HAVE_LIBX
的检查……类似:
#if (NGX_HAVE_LIBX)
libx_init();
#endif
它的工作原理就像是一种魅力。...当我运行auto/configure
时,我发现检测到该库的内容如下:
checking for libx... found
并在链接时编译 BUT ,在构建最终的-lx
二进制文件时,它不包括cc/ld
作为发送到objs/Nginx
的标志的一部分。我希望在auto/os/linux
中检测到该功能后,它会在创建Makefile时自动自动添加到链接阶段...但是显然不是这种情况,所以我知道遗漏了一些东西...我还需要执行什么其他步骤才能将其拉开?
这是在Nginx 1.19.2上(好吧,来自Nginx镜像的master
分支)。
解决方法
我想我明白了。
我需要添加以下内容:
+ngx_feature="libx"
+ngx_feature_name="NGX_HAVE_LIBX"
+ngx_feature_run=no
+ngx_feature_incs="#include <libx.h>"
+ngx_feature_path=
+ngx_feature_libs=-lx
+ngx_feature_test="libx_init();"
+. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lx"
NGX_LIBDL="-lx"
fi