定制的Apache2模块将不能与错误讯息和QUOT加载,无法定位API模块结构" [英] custom apache2 module will not load with error message "Can't locate API module structure"

查看:243
本文介绍了定制的Apache2模块将不能与错误讯息和QUOT加载,无法定位API模块结构"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Windows开发者,但目前正试图在这篇文章中描述的生成使用apxs2工具,在linux上一个非常简单的Apache2模块:HTTP://www.$c$cproject.com/Articles/491909/Apache- 2-X-模块多功能CPLUSPLUS-部分-1] [1]

模块正在成功打造,但不能加载某些原因。下面的错误在重新启动Apache问题:无法找到API模块结构

现在的一些细节。

所有想用下面的命令来构建模块的第一

  apxs2 -i -a -c mod_pixmongo.cpp

它失败,错误信息,即无法确定引导符号名,而必须指定一个选项`-n'

在提供-n选项模块正在成功地构建:

  apxs2 -i -a -n pixmongo -c mod_pixmongo.cpp

但是,试图重新启动以下错误Apache问题:

的Apache2:对/etc/apache2/mods-enabled/pixmongo.load第1行语法错误:在/etc/apache2/apache2.conf中的203行语法错误无法找到API模块结构`pixmongo_module在文件/usr/lib/apache2/modules/mod_pixmongo.so:/usr/lib/apache2/modules/mod_pixmongo.so:未定义的符号:pixmongo_module
行动configtest失败。

我知之甚少的Linux共享库,但建议该模块结构必须以某种方式出口。在我的理解下面的命令是为了显示导出符号:

 纳米-D /usr/lib/apache2/modules/mod_pixmongo.so

在我的情况下,它显示以下内容:

 W¯¯_Jv_RegisterClasses
0000000000200778一个__bss_start
             W¯¯__cxa_finalize
             W¯¯__gmon_start__
0000000000200778一个_edata
0000000000200788一个_end
0000000000000558ŧ_fini
0000000000000418ŧ_init

所以结构模块是不是真的有,我觉得它pretty奇怪。作为比较:其他pre-安装的模块有​​导出的结构。例如:

 纳米-D /usr/lib/apache2/modules/mod_info.soW¯¯_Jv_RegisterClasses
00000000002052b0一个__bss_start
             W¯¯__cxa_finalize
             W¯¯__gmon_start__
00000000002052b0一个_edata
00000000002052c0一个_end
0000000000002b48ŧ_fini
0000000000001708ŧ_init
**************一长串这​​里*********
00000002050e0Ðinfo_module
             üstrcasecmp
             üSTRCMP

所以,问题是我做错了什么。
任何帮助是非常AP preciated。
样品模块的源$ C ​​$ c是如下:

头文件mod_pixmongo.hpp:

 的#ifndef MOD_PIXMONGO_HPP
#定义MOD_PIXMONGO_HPP#IFDEF __cplusplus
#定义EXTERN_C_BLOCK_BEGIN的externC{
#定义EXTERN_C_BLOCK_END}
#定义EXTERN_C_FUNC的externC
#其他
#定义EXTERN_C_BLOCK_BEGIN
#定义EXTERN_C_BLOCK_END
#定义EXTERN_C_FUNC
#万一#包括LT&;&httpd.h中GT;
#包括LT&;&http_protocol.h GT;
#包括LT&;&http_config.h GT;#ENDIF / * * MOD_PIXMONGO_HPP /

来源文件mod_pixmongo.cpp:

 的#includemod_pixmongo.hppEXTERN_C_FUNC
INT pixmongo_handler(*的request_rec在prequest)
{
    INT nReturnVal =下降;如果(在prequest->!处理程序= NULL&放大器;&安培; STRCMP(以prequest->处理程序,pixmongo)== 0)
{
    ap_rputs(的Hello World从PIXMONGO,在prequest);
    nReturnVal = OK;
}返回nReturnVal;
}EXTERN_C_FUNC
无效pixmongo_hooks(apr_pool_t * inpPool)
{
ap_hook_handler(pixmongo_handler,NULL,NULL,APR_HOOK_MIDDLE);
}EXTERN_C_BLOCK_BEGIN
模块AP_MODULE_DECLARE_DATA pixmongo_module =
{
  STANDARD20_MODULE_STUFF,
空值,
空值,
空值,
空值,
空值,
pixmongo_hooks
};
EXTERN_C_BLOCK_END


解决方案

我意识到我的错误。实用APXS不能够打造C ++模块,但只有C(后者为我工作的罚款)。在上述$ C $的CProject文章APXS工具仅用于部署已编译的模块,但不进行编译。

I'm a windows developer but now trying to build a very simple apache2 module on linux using apxs2 tool as described in this article: [http://www.codeproject.com/Articles/491909/Apache-2-x-Modules-In-Cplusplus-Part-1][1]

The module is being successfully build but cannot be loaded for some reason. Apache issues following error on restart: "Can't locate API module structure".

Now some details.

First of all trying to build the module with following command

 apxs2 -i -a  -c mod_pixmongo.cpp

It fails with error message that it "cannot determine bootstrap symbol name" and that one must "specify one with option `-n'"

When option -n is supplied the module is being successfully built:

apxs2 -i -a -n pixmongo  -c mod_pixmongo.cpp

But an attempt to restart apache issues following error:

apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/pixmongo.load: Can't locate API module structure `pixmongo_module' in file /usr/lib/apache2/modules/mod_pixmongo.so: /usr/lib/apache2/modules/mod_pixmongo.so: undefined symbol: pixmongo_module Action 'configtest' failed.

I know little about shared libraries on linux but suggest that the module structure must be somehow exported. Following command in my understanding is supposed to show exported symbols:

nm -D /usr/lib/apache2/modules/mod_pixmongo.so

In my case it shows following:

w _Jv_RegisterClasses
0000000000200778 A __bss_start
             w __cxa_finalize
             w __gmon_start__
0000000000200778 A _edata
0000000000200788 A _end
0000000000000558 T _fini
0000000000000418 T _init

So the structure "module" is really not there and I find it pretty strange. To compare: any other pre-installed module have that structure exported. For example:

nm -D /usr/lib/apache2/modules/mod_info.so

w _Jv_RegisterClasses
00000000002052b0 A __bss_start
             w __cxa_finalize
             w __gmon_start__
00000000002052b0 A _edata
00000000002052c0 A _end
0000000000002b48 T _fini
0000000000001708 T _init
************** the long list here *********
00000002050e0 D info_module
             U strcasecmp
             U strcmp

So the question is what I'm doing wrong. Any help is very much appreciated. The source code of the sample module is below:

Header file mod_pixmongo.hpp:

#ifndef MOD_PIXMONGO_HPP
#define MOD_PIXMONGO_HPP

#ifdef __cplusplus
#define EXTERN_C_BLOCK_BEGIN    extern "C" {
#define EXTERN_C_BLOCK_END      }
#define EXTERN_C_FUNC           extern "C"
#else
#define EXTERN_C_BLOCK_BEGIN
#define EXTERN_C_BLOCK_END
#define EXTERN_C_FUNC
#endif

#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>

#endif  /* MOD_PIXMONGO_HPP */

Source file mod_pixmongo.cpp:

#include "mod_pixmongo.hpp"

EXTERN_C_FUNC
int pixmongo_handler( request_rec* inpRequest )
{
    int nReturnVal = DECLINED;

if ( inpRequest->handler != NULL && strcmp( inpRequest->handler, "pixmongo" ) == 0 )
{
    ap_rputs( "Hello World from PIXMONGO", inpRequest );
    nReturnVal = OK;
}

return nReturnVal;
}

EXTERN_C_FUNC
void pixmongo_hooks( apr_pool_t* inpPool )
{
ap_hook_handler( pixmongo_handler, NULL, NULL, APR_HOOK_MIDDLE );
}

EXTERN_C_BLOCK_BEGIN
module AP_MODULE_DECLARE_DATA pixmongo_module =
{
  STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
pixmongo_hooks
};
EXTERN_C_BLOCK_END

解决方案

I realized my mistake. Utility apxs is not capable to build C++ modules but only C (the latter worked fine for me). In the above mentioned codeproject article the apxs utility is only used to deploy already compiled module but not to compile it.

这篇关于定制的Apache2模块将不能与错误讯息和QUOT加载,无法定位API模块结构&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆