0

I have modified an nginx module in a way that it depends on a library.... let's call the library that I need libx.

I have modified auto/os/linux in such a way that I am able to detect if libx is present... by adding something like:

+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

Then, in the module code I do #ifs checking for NGX_HAVE_LIBX... something like:

#if (NGX_HAVE_LIBX)
   libx_init();
#endif

And it works like a charm.... when I run auto/configure I get that the library is detected with something like:

checking for libx... found

and it compiles BUT at link time it's not including -lx as part of the flags sent to cc/ld when building the final objs/nginx binary. I would have expected that after the feature be detected in auto/os/linux it would automagically be added to the linking phase when creating the Makefile... but apparently that's not the case so I know I am missing something... what additional step do I need to do to pull it off?

This is on nginx 1.19.2 (well, master branch from nginx mirror).

eftshift0
  • 26,375
  • 3
  • 36
  • 60

1 Answers1

0

I think I got it.

I needed to add something like this:

+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
eftshift0
  • 26,375
  • 3
  • 36
  • 60