Search code examples
apachebrotli

How to fix "undefined symbol: BrotliEncoderTakeOutput" when apache start


I have compiled mod_brotli.so, but when I restart apache, it cannot load module.

Error :

httpd: Syntax error on line 155 of /usr/local/apache2/etc/httpd.conf: Cannot load modules/mod_brotli.so into server: /usr/local/apache2/modules/mod_brotli.so: undefined symbol: BrotliEncoderTakeOutput


Solution

  • I am having the same problem. I don't know if it is the cause... in my case we are trying to add mod_brotli to Apache 2.4.34, from the Red Hat software collection (why they don't compile it with Brotli and include the Brotli package as a dependency, I have no idea).

    I am not C developer, coming from the admin side, I can't see why it isn't working. At first I thought it was an ldconfig issue, so I added a new file to the config dir, but it still doesn't work...

    # apachectl -M
    httpd: Syntax error on line 129 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf: Cannot load /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_brotli.so into server: /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_brotli.so: undefined symbol: BrotliEncoderTakeOutput
    

    Here you can see that ld knows about it, and that lib has the symbol...

    # ldconfig -p | grep brotli
    libbrotlienc.so.1 (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlienc.so.1
    libbrotlienc.so (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlienc.so
    libbrotlidec.so.1 (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlidec.so.1
    libbrotlidec.so (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlidec.so
    libbrotlicommon.so.1 (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlicommon.so.1
    libbrotlicommon.so (libc6,x86-64) => /usr/local/lib64/brotli/libbrotlicommon.so
    
    # nm /usr/local/lib64/brotli/libbrotlienc.so | grep BrotliEncoderTakeOutput
    0000000000090970 T BrotliEncoderTakeOutput
    

    Meanwhile, you can see the undefined symbol in mod_brotli:

    # nm /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_brotli.so | grep BrotliEncoderTakeOutput
    U BrotliEncoderTakeOutput
    

    Compiling the Apache module was done with

    apxs -i -c -I /usr/local/include/brotli/ mod_brotli.c
    

    Brotli itself was compiled from the latest tarball from github...

    Apache is otherwise running fine, with the brotli line commented out.

    Will post again if I find the answer...

    ====

    Edit:

    I got it working (well, having issues related to haproxy and h2c (unencrypted http2), but that's another matter)

    In my case, the two issues were

    A) I had compiled brotli in a bad way (based on some blog posts), compiling it per the google github readme worked

    B) I was compiling the module with apxs command, but it turns out that is only for third party modules. The correct way for Apache built in modules that just didn't get compiled originally is:

    ./configure --prefix=/opt/rh/httpd24/root/etc/httpd --enable-brotli --with-brotli=/usr/local
    

    and then make install (prefix is for the RH SCL version of course) (I actually did make install from the modules/filters/ dir, so it would install as little as possible as an override... not sure if it was needed, but that's what I did).

    I figured out B) first, but it wasn't picking up the Brotli libs, after A) it worked fully.

    I have no idea what apxs is doing differently, or why there should be different ways to compile modules, but hey.

    I hope this will be at least some help.