Apache Server configuration support - I write a apache module but it can't be loaded with error "undefined symbol: ap_s

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > May 2006 > I write a apache module but it can't be loaded with error "undefined symbol: ap_s





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author I write a apache module but it can't be loaded with error "undefined symbol: ap_s
zhengfish

2006-05-24, 7:17 am

HI,
I just want to test the apache module.
my first example and steps:
----------------------------------------------------------------------------------------------
# apxs -g -n hello
# make
# make install

# vi /etc/httpd/conf/httpd.conf
LoadModule hello_module modules/mod_hello.so
<Location /hello>
SetHandler hello
</Location>

# service httpd restart

It is ok when I test the URL http://server/hello
----------------------------------------------------------------------------------------------

But when I modify some code in the mod_hello.c like this:
// --BEGIN--
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "ap_config.h"

#include "apr_compat.h"
#include "http_core.h" /* <== added this extra include file */

/* The sample content handler */
/***
static int hello_handler(request_rec *r)
{
if (strcmp(r->handler, "hello")) {
return DECLINED;
}
r->content_type = "text/html";

if (!r->header_only)
ap_rputs("The sample page from mod_hello.c\n", r);
return OK;
}
***/
/* The content handler */
static int hello_handler(request_rec *r)
{
const char* remote_host;
const char* user_agent;

r->content_type = "text/html";
ap_send_http_header(r);
if (r->header_only)
return OK;

remote_host = ap_get_remote_host(r->connection,
r->per_dir_config,
REMOTE_NAME,
NULL);
user_agent = ap_table_get(r->headers_in,"User-Agent");

ap_rputs("<HTML><HEAD><TITLE>Greetings</TITLE></HEAD></BODY>\n",r);
ap_rputs("<H1>Greetings, Earthling</H1>\n",r);
ap_rprintf(r,"<P>Hello to you, <b>%s</b>.</P>\n",remote_host);
ap_rprintf(r,
"<P>You are the lucky user of a <i>%s</i>
browser.</P><hr>\n",
user_agent);

if (r->path_info && strlen(r->path_info) > 0)
ap_rprintf(r, "<P>Path info = <b>%s</b></P><hr>\n", r->path_info);

if (r->args && strlen(r->args) >0 )
ap_rprintf(r, "<P>Query string = <b>%s</b></P><hr>\n", r->args);

ap_rputs("</BODY></HTML>\n",r);

return OK;
}

static void hello_register_hooks(apr_pool_t *p)
{
ap_hook_handler(hello_handler, NULL, NULL, APR_HOOK_MIDDLE);
}

/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA hello_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* table of config file commands */
hello_register_hooks /* register hooks */
};
// --END--

THEN it is failed like this:
# make
# make install
# service httpd configtest
Syntax error on line 208 of /etc/httpd/conf/httpd.conf:
Cannot load /etc/httpd/modules/mod_hello.so into server:
/etc/httpd/modules/mod_hello.so: undefined symbol: ap_send_http_header

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com