httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sorin Manolache" <sor...@gmail.com>
Subject Re: multiple source files in a single apache module
Date Tue, 13 Jan 2009 21:04:06 GMT
On Tue, Jan 13, 2009 at 21:48, wolfgang <wolfgang127@gmail.com> wrote:
> Hi gurus,
>
> I made a sample apache module, mod_test, by
> "/usr/local/apache/bin/apxs -g -n test".
> Now I want to make the mod_test call the following source ( actually,
> an add_test function ).
>
> ----------- my_test.h ------------
> #ifndef _MY_TEST_H
> #define _MY_TEST_H 1
>
> int add_test(int a, int b);
>
> #endif
> ----------------------------------------
>
> ------------ my_test.c -----------
> #include "my_test.h"
>
> int add_test(int a, int b){
>  return (a+b);
> }
> ----------------------------------------
>
> I've added #include "my_test.h" in mod_test.c and also add_test(10,20)
> in the test_handler function as follows.
>
> /* The sample content handler */
> static int test_handler(request_rec *r)
> {
>    if (strcmp(r->handler, "test")) {
>        return DECLINED;
>    }
>    r->content_type = "text/html";
>
>    printf("test_handler is called\n");
>
>    if (!r->header_only){
>        ap_rputs("The sample page from mod_test.c\n", r);
>        printf("%d\n", add_test(10,20));  // <--- HERE !!!
>    }
>    return OK;
> }
>
> and compiled and installed as follows
> ( I've added LoadModule, SetHandler in httpd.conf )
>
> $ make
> $ make install
>
> run apache as debug mode
> $ /usr/local/apache/bin/httpd -X
>
> Then, I get the following error.
>
> httpd: Syntax error on line 100 of /usr/local/apache/conf/httpd.conf:
> Cannot load /usr/local/apache/modules/mod_test.so into server:
> /usr/local/apache/modules/mod_test.so: undefined symbol: add_test
>
> Of course, I get the error since I haven't modified Makefile at all.
>
> Now, my question is how Makefile should be modified ???
>
> -------------------------------------
> #   the used tools
> APXS=apxs
> APACHECTL=apachectl
>
> #   additional defines, includes and libraries
> #DEFS=-Dmy_define=my_value
> #INCLUDES=-Imy/include/dir
> #LIBS=-Lmy/lib/dir -lmylib
>
> #   the default target
> all: local-shared-build
>
> #   install the shared object file into Apache
> install: install-modules-yes
>
> #   cleanup
> clean:
>  -rm -f mod_test.o mod_test.lo mod_test.slo mod_test.la
> -------------------------------------

Please attach your whole Makefile.

Please indicate the list of source files. As far as I understood, you
have mod_test.h and mod_test.c that contain the declaration and
definition of add_test. Which file contains test_handler and the
test_module structure?

--
S

>
> I'm stuck over 8 hours... I couldn't find any sites describing this
> kinda situation.
> I'm really new to Makefile but no time to learn Makefile from a
> scratch right now.... :(
> Please please please help me out...
>
> thanks in advance.
>
> wolfgang
>



-- 
A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Mime
View raw message