Subject: Problems when compiling as DSO module (and workaround)

From: Guillaume Filion <[email-masked]>
Date: Sat, 13 Jul 2002 09:33:05 -0400

Hi all,

I'm trying to compile mod_ssl-2.8.10-1.3.26 as a DSO (APXS) module on 
my Debian box, but I got two problems:
First, when doing make, I got:
mod_ssl.h:349:18: ndbm.h: No such file or directory
This is the same problem as described at 
http://www.mail-archive.com/[email-masked]/msg13487.html

On my system ndbm.h is located in /usr/include/db1/, so I added 
-I/usr/include/db1/ in pkg.sslmod/Makefile.

It did compile and install well, but when I tried to start Apache, I got this:
ali:/www# bin/apachectl start
Syntax error on line 208 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libssl.so into server: 
/usr/local/apache/libexec/libssl.so: undefined symbol: dbm_firstkey
bin/apachectl start: httpd could not be started
This is the same problem as described at 
http://www.mail-archive.com/[email-masked]/msg13505.html

Devon Bleak found a workaround to the problem in: 
http://www.mail-archive.com/[email-masked]/msg10438.html

So, in short, here's what I did to make it work:
apt-get install libgdbmg1 libgdbmg1-dev
./configure --with-apxs=/www/bin/apxs
Make these substitutions in pkg.sslmod/Makefile :
6c6
< CFLAGS=-I$(INCDIR) -DLINUX=22 -DUSE_HSREGEX -DEAPI -DUSE_EXPAT 
-I../lib/expat-lite
---
>  CFLAGS=-I$(INCDIR) -DLINUX=22 -DUSE_HSREGEX -DEAPI -DUSE_EXPAT 
>-I../lib/expat-lite -I/usr/include/db1
11c11
< LIBS_SHLIB=
---
>  LIBS_SHLIB= -lgdbm
make
make install
Modify my Apache configuration to add this line plus the other mod_ssl stuff:
LoadModule ssl_module         libexec/libssl.so

When I build mod_ssl statically into Apache these problems do not not occur.

These problems seem to have been present for a long time (Devon 
Bleak's workaround dates from February) and do not seem to be really 
hard to solve, just a bit a configure bork bork and it would find the 
right headers and libs. This really would make my life easier. 8)

Also, when I make install, apxs doesn't seem to modify my 
configuration file like it does with other apxs modules, is this a 
wanted behavior?
ali:/home/gfk/making-webserver/mod_ssl-2.8.10-1.3.26# make install
make[1]: Entering directory 
`/home/gfk/making-webserver/mod_ssl-2.8.10-1.3.26/pkg.sslmod'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory 
`/home/gfk/making-webserver/mod_ssl-2.8.10-1.3.26/pkg.sslmod'
cp libssl.so /usr/local/apache/libexec/libssl.so
chmod 755 /usr/local/apache/libexec/libssl.so
ali:/home/gfk/making-webserver/mod_ssl-2.8.10-1.3.26#

Also, mod_ssl is a *great* tool, but I guess you allready know that! 8)

Regards,
GFK's
-- 
Guillaume Filion
Logidac Tech., Beaumont, Québec, Canada - http://logidac.com/
PGP Key and more: http://guillaume.filion.org/      (this will redirect)
PGP Fingerprint: 14A6 720A F7BA 6C87 2331 33FD 467E 9198 3DED D5CA
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [email-masked]
Automated List Manager                            [email-masked]

---

From: Guillaume Filion <[email-masked]>
Date: Mon, 15 Jul 2002 21:47:30 -0400

Hi all,

I tried to figure out what caused these two problems, here's what I found.

I think that the problem is with apxs, it only gets the CFLAGS 
configured at Apache's compile time. And they are not right for every 
module that one will want to add to Apache.

Take for example ndbm.h which is needed by mod_ssl. When compiling 
mod_ssl statically into Apache, there's no problem since Apache takes 
care of finding where it is located. But when we're building mod_ssl 
with apxs, if Apache's configure has not figured out where ndbm.h is, 
compilation will fail.

Here's an example:

$ tar zxf apache_1.3.26.tar.gz
$ cd apache_1.3.26

$ ./configure --enable-module=so
$ make
$ make install
$ /usr/local/apache/bin/apxs -q CFLAGS
-DLINUX=22 -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite

apxs does not provide the location of ndbm.h since configure didn't needed it.

$ cd ..
$ rm -rf apache_1.3.26
$ tar zxf apache_1.3.26.tar.gz
$ cd apache_1.3.26

If, for example, I enable mod_rewrite which requires DBM support, 
apxs will "know" where to look for DBM.

$ ./configure --enable-module=so --enable-module=rewrite
[...]
  + adding selected modules
     o rewrite_module uses ConfigStart/End
  + using -ldb1 for DBM support
       enabling DBM support for mod_rewrite
[...]
$ make
$ make install
$ /usr/local/apache/bin/apxs -q CFLAGS
-DLINUX=22 -I/usr/include/db1 -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite

This is wrong since not enabling a module that requires DBM doesn't 
mean that I'll never want to add one that does in the future.

I don't see any trivial solution to this problem. The easier one, 
IMHO, is to do every check when mod_so is enabled.

It's a similar problem for the DBM library, src/Makefile stores it into:
LIBS1=  -lm -lcrypt -ldb1 -ldl
[...]
LIBS=$(EXTRA_LIBS) $(LIBS1)
but this is not exported to apxs. I'm not sure if it should.

Am I making some sense here? What do people think about this? Should 
I file a bug report to Apache about this? I searched bugs.apache.org 
about this but I couldn't find a single bug about apxs...

I think I need a drink! 8)
GFK's