logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

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

or

Bitcoin

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

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: Undefined references in Apache user-written module
Author
DrKlahn



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" ...

Code:
#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,
                                          &test_module);

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

  return 0;
}

module AP_MODULE_DECLARE_DATA test_module = {
        STANDARD20_MODULE_STUFF,NULL,NULL,NULL,NULL,NULL,NULL};


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.)

Code:
APXS=/usr/local/apache2/bin/apxs
APXS_OPTS=-Wc, -Wc,-DDST_CLASS=3
SRC=src/mod_test.c
OBJ=src/.libs/mod_test.so

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

clean:
        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:

Code:
/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
Jan-E



Joined: 09 Mar 2012
Posts: 1248
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
DrKlahn



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
DrKlahn



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


Reply to topic   Topic: Undefined references in Apache user-written module View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads