PHP with gettext support on Mac OS X

PHP comes installed on OS X by default but it doesn’t come compiled with gettext support. So once you try to do something with gettext you will likely see something like this error message:

Fatal error: Call to undefined function bindtextdomain()

At this point you might be tempted to recompile PHP to add gettext but in fact there’s a better way, you can simply add it as a dynamically loaded library.

To do that download your version of php and do the following:

(inside the php directory)
cd ext/gettext
MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure
sudo make install

When done, edit your php.ini (normally located in /etc) and add:


Next just restart apache and you should be all done.

Update: Also you can get a binary package from