Problems building mod_perl on Mountain Lion (MacOSX 10.8)

Over the weekend I upgraded my laptop to Mountain Lion, and decided to install Perl 5.16.2. I had problems getting mod_perl working. This is a summary of the problem and the (a?) solution, in the hope it might save others from banging their heads against it.

I had previously installed Perl 5.16.1, Apache 2.2.22, and mod_perl 2.0.7 on MacOS X 10.7.5, and all went ok. This past weekend I decided to upgrade to 10.8.2, and thought I'd upgrade to perl 5.16.2 as well. After installing Mountain Lion, I installed Xcode, and then installed the command-line tools (resisting comment on that). To get the compiler working correctly, I had to refer to this stackoverflow question.

I followed my usual sequence: openssl, apache, perl. Everything compiled with no problem. But when I installed mod_perl 2.0.7 and tried to start apache, I got the following error:

  httpd: Syntax error on line 60 of /usr/local/apache/conf/httpd.conf:
    Cannot load /usr/local/apache/modules/ into server:
    dlopen(/usr/local/apache/modules/, 10):
    Symbol not found: _modperl_handler_name
    Referenced from: /usr/local/apache/modules/ Expected in: dynamic lookup

I'll spare you the gory details, but the problem was caused by the fact that there are two different C compilers, their interpretation of inline is different, and different configure processes pick up different compilers.

  % /usr/bin/cc --version | head -1
  Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)

  % /usr/bin/gcc --version | head -1
  i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

OpenSSL, Apache, and the apache portable runtime (APR) were all built with gcc. But Perl's Configure was picking up cc. So when building mod_perl, it was referring to an APR built with gcc, but Perl's config was telling it to use cc. Rebuilding everything and ensuring gcc was used throughout resolved the issue.

1 Comment

The following steps worked for me (OSX 10.8.5):

(1) Compiling and installing httpd-2.2.27:
Execute configure like this:
CFLAGS=-std=gnu89 ./configure --prefix=HTTPD_PREFIX --enable-mods-shared=all --with-included-apr

HTTPD_PREFIX: anywhere you want. Next, as usual:
make install

(2) Compiling and installing mod_perl:
perl Makefile.PL MP_CCOPTS=-std=gnu89 MP_APXS=HTTPD_PREFIX/bin/apxs
[sudo] make install

As Neil said, the point is on the inline interpretation.

My GCC version:
gcc -v:
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

Leave a comment

About Neil Bowers

user-pic Perl hacker since 1992.