How to compile apache module with included sds library using apxs2

144 views Asked by At

I get example apache2 module here:

https://httpd.apache.org/docs/2.4/developer/modguide.html

and I want to use there this sds library https://github.com/antirez/sds

So I will create new module and goto module dir:

apxs -g -n mymodule
cd mod_mymodule

add on line 44 of mod_mymodule.c:

#include "sds.h"

and into the mymodule_handler on line 49 I will add

sds a = sdsnew("a");
sds b = sdsnew("b");
if (sdscmp(a, b) == 0) 
    return (DECLINED);

I also put library files (sds.c, sds.h, sdsalloc.h) into the same directory as my module source code file and then I will call:

sudo apxs -i -a -c mod_mymodule.c

Then I will restart apache, but it fails to start because of:

apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/mymodule.load: Cannot load /usr/lib/apache2/modules/mod_mymodule.so into server: /usr/lib/apache2/modules/mod_mymodule.so: undefined symbol: sdscmp

Question: How can I modify apxs command to make my new module work with included library?

1

There are 1 answers

1
covener On BEST ANSWER

If you want to link them together into your module, you'd pass in all the .c files. Keep the one that's a module first otherwise you have to also pass -n for the module name.

If "sds" were instead an installed library, you'd pass -lsds to apxs just as you would to compiple without apxs.