Mountain Lion, PHP and Clang

It seems that Apple has finally ditched gcc and any remnants of it in Mountain Lion (OS X 10.8). This has been a while in coming so should surprise nobody. If you think you have gcc, fire off an ‘ls -la /usr/bin/gcc’ and see the symlink glory.

I’ll write a more comprehensive post on compiling php, httpd, lib*, openssl, etc. when I have the time. But to share the most important piece of the puzzle, you must use the -lresolv flag when compiling php (and make sure to use the darwin 64-bit configure of openssl). You must also have libmysqlclient.18.dylib in the correct place. For some reason, the library load paths in my .bashrc are being ignored. The easiest way to do this is:

#ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

So here is part of my standard php config.nice:

‘export EXTRA_CFLAGS=-lresolv ‘\
‘./configure’ \
‘–prefix=/usr/local/php’ \
‘–with-apxs2=/usr/local/apache-2.2.22/bin/apxs’ \
‘–with-mysql=/usr/local/mysql/’ \
‘–with-mysqli=/usr/local/mysql/bin/mysql_config’ \
‘–with-gd’ \

If you don’t do the above, you’ll most likely result in this error (yes, keyword stuffing):

Undefined symbols for architecture x86_64:
“_res_9_dn_expand”, referenced from:
_php_parserr in dns.o
_zif_dns_get_mx in dns.o
“_res_9_dn_skipname”, referenced from:
_zif_dns_get_record in dns.o
_zif_dns_get_mx in dns.o
“_res_9_init”, referenced from:
_zif_dns_check_record in dns.o
_zif_dns_get_record in dns.o
_zif_dns_get_mx in dns.o
“_res_9_search”, referenced from:
_zif_dns_check_record in dns.o
_zif_dns_get_record in dns.o
_zif_dns_get_mx in dns.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libs/libphp5.bundle] Error 1

My other post on compiling 64-bit AMP on 10.5.x is surprisingly relevant still.

More soon.

Hey, like this post? Why not share it with a buddy?

Leave a Comment