httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: Re: [users@httpd] writing my first own module - can't determine bootstrap symbol name; undefined API module structure
Date Thu, 02 May 2013 13:14:35 GMT
On Thu, May 2, 2013 at 1:17 PM, oneat <oneat@vp.pl> wrote:
> On Thu, May 2, 2013 at 12:22 PM, oneat <oneat@vp.pl> wrote:
>> Hi.
>>
>> I'm writing my first module in c++ for apache and this is its code in
>> mod_cpp.cpp file:
>>
>> module AP_MODULE_DECLARE_DATA  cpp_module =
>> {
>>    STANDARD20_MODULE_STUFF,
>>    NULL,
>>    NULL,
>>    NULL,
>>    NULL,
>>    NULL,
>>    register_hooks
>> };
>>
>> static int handle(request_rec *r){
>>
>> ap_set_content_type(r, "text/html");
>> ap_rprintf(r, r->filename);
>>
>> }
>>
>> static void register_hooks(apr_pool_t *pool)
>> {
>>    /* Create a hook in the request handler, so we get called when a request
>> arrives */
>>    ap_hook_handler(handle, NULL, NULL, APR_HOOK_LAST);
>> }
>>
>> However when I try to compile it install and actibvate by apxs -i -a -c
>> mod_cpp.cpp I get:
>>
>> [oneat@localhost ~]$ sudo apxs -iac  mod_cpp.cpp
>> /usr/lib/apr-1/build/libtool --silent --mode=link gcc -std=gnu99
>> -Wl,-z,relro,-z,now  -o mod_cpp.la  -rpath /usr/lib/httpd/modules -module
>> -avoid-version    mod_cpp.cpp
>> apxs:Error: Sorry, cannot determine bootstrap symbol name.
>> apxs:Error: Please specify one with option `-n'.
>>
>> then I tried
>>
>> sudo apxs -iac -n cpp mod_cpp.cpp
>>
>> and everything went well, but when I try to start apache I get:
>>
>> httpd: Syntax error on line 55 of /etc/httpd/conf/httpd.conf: Can't locate
>> API module structure `cpp_module' in file /usr/lib/httpd/modules/mod_cpp.so:
>> /usr/lib/httpd/modules/mod_cpp.so: undefined symbol: cpp_module
>>
>> Any ideas why?
>>
>> Regards, Peter.
>>
>>
>>>>>>>>>>>>>>>>
>>Are you sure you're declaring anything you expect apache to be able to
>>find as extern C?
>
> ..>Try adding this line in your cpp file, before you declare cpp_module:
>
>>extern module cpp_module;
>
>>Cheers
>
>>Tom
>
> I used extern "C" without any success (bracing whole code or typed extern before module).
I tried changing name of file from mod_cpp.cpp to mod_cpp.c but the it even doesn't compile:
> mod_cpp.c:1:1: error: unknown type name 'module'
> mod_cpp.c:1:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cpp_module'
> mod_cpp.c:12:19: error: unknown type name 'request_rec'
> mod_cpp.c:19:28: error: unknown type name 'apr_pool_t'
>

Don't rename it to .c, it is not C. You need to include the header
that defines the module type (http_config.h) before declaring that
your cpp_module is extern.

If you are still having problems, strip down your code to the raw
basics and post it.

Cheers

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message