简体   繁体   English

如何使用 apxs2 编译包含 sds 库的 apache 模块

[英]How to compile apache module with included sds library using apxs2

I get example apache2 module here:我在这里得到示例 apache2 模块:

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

and I want to use there this sds library https://github.com/antirez/sds我想在那里使用这个 sds 库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:在 mod_mymodule.c 的第 44 行添加:

#include "sds.h"

and into the mymodule_handler on line 49 I will add并在第 49 行的 mymodule_handler 中添加

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:我还将库文件(sds.c,sds.h,sdsalloc.h)放入与我的模块源代码文件相同的目录中,然后我将调用:

sudo apxs -i -a -c mod_mymodule.c

Then I will restart apache, but it fails to start because of:然后我会重启apache,但是启动失败是因为:

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?问题:如何修改 apxs 命令以使我的新模块与包含的库一起使用?

If you want to link them together into your module, you'd pass in all the.c files.如果你想将它们链接到你的模块中,你需要传入所有的 .c 文件。 Keep the one that's a module first otherwise you have to also pass -n for the module name.首先保留一个模块,否则您还必须通过 -n 作为模块名称。

If "sds" were instead an installed library, you'd pass -lsds to apxs just as you would to compiple without apxs.如果“sds”是一个已安装的库,您可以将 -lsds 传递给 apxs,就像在没有 apxs 的情况下进行编译一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM