httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wolfgang <>
Subject multiple source files in a single apache module
Date Tue, 13 Jan 2009 20:48:12 GMT
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);


------------ 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/ into server:
/usr/local/apache/modules/ 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

#   additional defines, includes and libraries
#LIBS=-Lmy/lib/dir -lmylib

#   the default target
all: local-shared-build

#   install the shared object file into Apache
install: install-modules-yes

#   cleanup
  -rm -f mod_test.o mod_test.lo mod_test.slo

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.


View raw message