[英]Linking a static library to an Apache module
I am experimenting with Apache module development and therefore I'd like to know how to link a static library to a module (if it is even possible). 我正在尝试开发Apache模块,因此我想知道如何将静态库链接到模块(如果可能的话)。
Naturally it compiles and installs nicely and Apache fails when the module is loaded. 自然地,它可以很好地编译和安装,并且在加载模块时Apache会失败。 The message is:
消息是:
Cannot load /usr/lib/apache2/modules/mod_example.so into server: /usr/lib/apache2/modules/mod_example.so: undefined symbol: zmq_socket
The library I want to link is zeromq, I am using the makefile generated by apxs2
. 我要链接的库是zeromq,我正在使用
apxs2
生成的makefile。 Here I added -lzmq
. 在这里,我添加了
-lzmq
。 If I remove zmq related code, the module runs fine. 如果删除与zmq相关的代码,则该模块运行正常。
My platform is Ubuntu 12.04 64 bit, gcc4.6.3. 我的平台是Ubuntu 12.04 64位gcc4.6.3。
well, apparently the generated makefile is not a good idea. 好吧,显然生成的makefile不是一个好主意。 I replaced the makefile references with basic compilation commands, eg:
我用基本的编译命令替换了makefile引用,例如:
apxs2 -c -lzmq mod_example.c
alk's suggestion in the comment of the question would also work (adding library location to LD_LIBRARY_PATH
), since I was linking another apache-related library (apreq), which linked without any problems. alk在问题注释中的建议也可以工作(将库位置添加到
LD_LIBRARY_PATH
),因为我正在链接另一个与apache相关的库(apreq),该库没有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.