"undefined symbol" error while running JNI_CreateJavaVM function in Apache module

256 views Asked by At

I would like to init JVM in Apache module via ap_hook_pre_config fun but when I run XAMPP, this error occurs:

XAMPP: Starting Apache...fail.

httpd: Syntax error on line 158 of /opt/lampp/etc/httpd.conf: Cannot load modules/mod_hotcup.so into server: /opt/lampp/modules/mod_hotcup.so: undefined symbol: JNI_CreateJavaVM

It's strange because it compiles normally.

Any ideas what is missed?

I use Ubuntu 18, Java 11. Here's source code mod_hotcup.c

1

There are 1 answers

0
Mathieu On BEST ANSWER

Your problem comes from the arguments order when invoking ld:

Libraries to link must after the code to link.

Instead of

ld -Bshareable -o mod_hotcup.so mod_hotcup.o

It should be

ld -Bshareable -o mod_hotcup.so mod_hotcup.o -L${LIBPATH} -ljvm