Apache Lounge



Forum Index Downloads Search Register Log in  RSS Apache Lounge

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.

Undefined references in Apache user-written module

Post new topic   Reply to topic    Apache Forum Index -> Apache Building & Member Downloads

View previous topic :: View next topic  
Author Message

Joined: 25 Jan 2019
Posts: 3
Location: USA

PostPosted: Fri 25 Jan '19 21:48    Post subject: Undefined references in Apache user-written module Reply with quote

(This has also been posted on Stack Exchange but with only 2 views, results there are not promising so far.)

I have some undefined reference errors in an Apache module. I've cut the source code down to a minimum that reproduced the error. Below is the source for "mod_test.c" ...

#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_core.h"
#include "http_main.h"
#include "http_log.h"
#include "ap_mpm.h"
#include "apr_strings.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>

module AP_MODULE_DECLARE_DATA test_module;

static int test_handler(request_rec *r);
static int test_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s);

/* Structure containing state information for the module */

typedef struct {
} ns_mod_config;

static int ns_typematch(request_rec *r) {

  ns_mod_config *ns_scfg = ap_get_module_config(r->server->module_config,

  core_request_config *creq_cfg;
  creq_cfg = ap_get_core_module_config(r->request_config);

  return 0;

module AP_MODULE_DECLARE_DATA test_module = {

I am using a more-or-less standard Makefile for compiling the module (the install option was removed as this is a test to demonstrate the problem.)


$(OBJ): $(SRC)
        $(APXS) $(APXS_OPTS) -c $(SRC)
        @echo write '"make install"' to install module

        rm -f src/.libs/*
        rm -f src/*.o
        rm -f src/*.lo
        rm -f src/*.la
        rm -f src/*.slo
        rmdir src/.libs

The compile fails as follows:

/usr/local/apache2/bin/apxs -Wc, -Wc,-DDST_CLASS=3 -c src/mod_test.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/apache2/include  -I/usr/local/apache2/include   -I/usr/local/apache2/include   -DDST_CLASS=3  -c -o src/mod_test.lo src/mod_test.c && touch src/mod_test.slo
src/mod_test.c: In function ‚ns_typematch‚:
src/mod_test.c:34:3: error: unknown type name ‚core_request_config‚
   core_request_config *creq_cfg;
src/mod_test.c:35:14: warning: implicit declaration of function ‚ap_get_core_module_config‚ [-Wimplicit-function-declaration]
   creq_cfg = ap_get_core_module_config(r->request_config);
src/mod_test.c:35:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   creq_cfg = ap_get_core_module_config(r->request_config);
apxs:Error: Command failed with rc=65536
Makefile:23: recipe for target 'src/.libs/mod_test.so' failed
make: *** [src/.libs/mod_test.so] Error 1

I am not sure how this can occur.

http_core.h is present in /usr/local/apache2/include and examining it shows that it does include the definitions claimed missing by the compiler.

Six other modules on the same system compile without errors, though none of them use this specific code to reference the core data structures.

Help will be gratefully received.
Back to top

Joined: 09 Mar 2012
Posts: 977
Location: Amsterdam, NL, EU

PostPosted: Sat 26 Jan '19 5:22    Post subject: Reply with quote

Googling I found the usage of more or less the same code in Apache itself:
http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/protocol.c?view=markup#l110 (line 126)
Do not know if you can use it, but it is wotyh mentioning.
Back to top

Joined: 25 Jan 2019
Posts: 3
Location: USA

PostPosted: Sat 26 Jan '19 19:12    Post subject: Reply with quote

Thanks providing that citation. This confirms that the code looks OK, as it appears to have no significant different from the code that I am using.
Back to top

Joined: 25 Jan 2019
Posts: 3
Location: USA

PostPosted: Sun 27 Jan '19 23:06    Post subject: Reply with quote

After posting to the Apache modules mailing list, it develops that the problem is in two parts.

1. Defining CORE_PRIVATE is required under Apache 2.2 to have access to the core data structures.

2. ap_get_core_module_config is an Apache 2.4 construct.
Back to top

Post new topic   Reply to topic    Apache Forum Index -> Apache Building & Member Downloads
Page 1 of 1