You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by miim <xx...@yahoo.com.INVALID> on 2019/01/26 23:45:52 UTC
Reference to core request fails during compile
I have undefined reference errors in an Apache module. I've cut the source code down to a minimum that reproduces 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,
&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 (note that the install option has been removed as this is a test to demonstrate the problem.)
----------------------------------------------------------------------------
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:
----------------------------------------------------------------------------
/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 it does include the definitions that are claimed missing by the compile.
There is a nearly identical chunk of code used in Apache itself -- q.v. http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/protocol.c?view=markup#l110
Six other modules on the same system compile without errors, though none of them use this specific reference to the core data structures.
I am forced to believe that it is a problem in the APXS compilation, though there is so much going on behind the scenes that I wouldn't know where to start looking.
Re: Reference to core request fails during compile
Posted by Eric Covener <co...@gmail.com>.
On Sat, Jan 26, 2019 at 6:46 PM miim <xx...@yahoo.com.invalid> wrote:
>
> I have undefined reference errors in an Apache module. I've cut the source code down to a minimum that reproduces 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,
> &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 (note that the install option has been removed as this is a test to demonstrate the problem.)
>
> ----------------------------------------------------------------------------
> 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:
>
> ----------------------------------------------------------------------------
> /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);
is /usr/local/apache2 Apache 2.2.x instead of 2.4.x?
2.2 is far past end of support, but:
- 2.2 required modules to define CORE_PRIVATE before seeing this structure.
- 2.2 also has no ap_get_core_module_config so you can't use that
2.4-ism (this is actually the 2nd error quoted above)