Discussion » mod_caml linking issue

I'm attempting to build mod_caml 1.3.6 for apache2 (with the PCRE issue patched, and on an arch where there are no debian binary packages). There are linking problems with the provided makefile.

make -n mod_caml.so
ocamlc -linkall -custom -g -w s -I /usr/lib/ocaml/3.08/pcre dynlink.cma \
 str.cma pcre.cma unix.cma mod_caml_c.o apache_c.o wrappers.o apache.cmo \
 mod_caml_config.cmo mod_caml.cmo cgi_escape.cmo template.cmo cgi.cmo -o \
 mod_caml.so -cclib "-I/usr/include/apache2 -I/usr/include/apr-0/ -pipe \
 -I/usr/include/xmltok -I/usr/include/openssl -Wall -O2   -lcamlrun \
 -ltermcap -lunix -lstr "

reports missing symbols beginning in ap_ , such as ap_hook_handler and ap_rwrite. These symbols are defined in the apache2 binary according to nm -D .

Apparently other modules such as mod_cgi do not define them either, and are linked using "apxs2 -c".

So for the linking step to work, it should either be done with apxs2 -c from .o files, or with ocamlc or ocamlopt, but without attempting to link the apache symbols in. Can someone help me with this?

----

It's perfectly normal for mod_caml.so to have undefined references to ap_* symbols. Those symbols are meant to be resolved when the module is loaded into Apache.

BTW, if you have questions about mod_caml, ask them on the mailing list.

Richard W.M. Jones

---

I agree the symbols should stay unresolved, the problem was ocamlc didn't know it. I had sent a message to the list a while ago that didn't get answers, but now I have a fix, involving the -cc flag of ocamlc and apxs:

--- /home/g2p/Construction/mod_caml-1.3.6/Makefile 2005-02-02 09:56:17.000000000 +0100 +++ /home/g2p/Construction/CVS/modcaml/Makefile 2005-05-27 17:45:47.633080640 +0200 @@ -67,13 +67,16 @@

	< $< > $@

500mod_caml.info: 500mod_caml.info.in Makefile.config
	sed -e 's,@APACHELIBDIR@,$(APACHELIBDIR),g' < $< > $@

+apxswrapper: apxswrapper.in + sed -e "s|\@APXS\@|$(APXS)|" $< > $@ + chmod +x $@


-mod_caml.so: mod_caml_c.o apache_c.o wrappers.o $(ALL_CMOS) - $(OCAMLC) -linkall -custom $(OCAMLCFLAGS) $(ALL_CMAS) $^ -o $@ \ +mod_caml.so: mod_caml_c.o apache_c.o wrappers.o $(ALL_CMOS) | apxswrapper + $(OCAMLC) -cc "./apxswrapper" -linkall -custom $(OCAMLCFLAGS) $(ALL_CMAS) $^ -o $@ \

	  -cclib "$(CFLAGS) $(LDFLAGS_SHLIB) $(OCAMLLIBS)"

example-handlers: registry.cmo examples/simple-handlers/print_trans.cmo \
	examples/simple-handlers/auth_simple.cmo

--- /home/g2p/Construction/mod_caml-1.3.6/apxswrapper.in 1970-01-01 01:00:00.000000000 +0100 +++ /home/g2p/Construction/CVS/modcaml/apxswrapper.in 2005-05-27 17:39:58.000000000 +0200 @@ -0,0 +1,2 @@ +#!/bin/sh +@APXS@ -c $@ && mv .libs/mod_caml.so . </nowiki>

There is a libtool warning when linking, but it seems the only way to build it (for apache2 at least); the resulting binary works fine with the examples.