Adding Gettext Extension for Mac OS X Leopard
I just installed a Gallery2 in this hosting and I just wanted to install a test gallery in my local Mac for testing and developing themes, but unfortunately, The PHP5 pre-installed in Leopard has not GD library and gettext enabled (or means installed). The tutorial of installation of GD library for Leopard can be found in Alex’s site: Adding the GD Extension to PHP5 on OS X Server 10.5.x. And next, I’ll tell you how to enable gettext extension for leopard’s PHP5.
Well… let’s go!
1.Requirements
- You have made a backup of your system.
- You have the latest version of Apple’s Developer Tools (XCode 3.0 or higher for 10.5.x) installed. Dev Tools are available on your Server DVD and as a free download from Apple’s Developer Connection.
- X11 is installed (part of standard OS X Server install unless you deselect it)
- X11 SDK is installed (available on your OS X Developer Tools Disc or Image and part of the standard installation. This is different from the X11 client that comes with OS X.)
- You do have a backup
- You are running 10.5.x
- You have not manually installed (or updated) anything related to gettext, if you have, you must know how to adapt these instructions to the changes you made.
2. Getting gettext and Installing gettext-runtime.
Open your Terminal and type:
For 32-bit :
mkdir -p /SourceCache
cd /SourceCache
curl -O ftp://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
tar xzpf gettext-0.17.tar.gz
cd /SourceCache/gettext-0.17/gettext-runtime
./configure
sudo make
sudo make install
For 64-bit :
mkdir -p /SourceCache
cd /SourceCache
curl -O ftp://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
tar xzpf gettext-0.17.tar.gz
cd /SourceCache/gettext-0.17/gettext-runtime
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure --enable-shared
sudo make
sudo make install
Now, libintl.h has been installed in your /usr/local/include. gettext cannot be installed if we have not libintl.h located in our Mac.
3. Installation of gettext
Download PHP-5.2.4 (or php-5.2.5) source code in PHP official site. or you can download it by using your Terminal.
cd /SourceCache
curl -O http://www.opensource.apple.com/darwinsource/10.5/apache_mod_php-43/php-5.2.4.tar.bz2
tar xjf php-5.2.4.tar.bz2
cd /SourceCache/php-5.2.4/ext/gettext
sudo phpize
Then,For 32-bit:
./configure
sudo make
sudo make install
For 64-bit use:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure
sudo make
sudo make install
4. Integration of gettext and PHP
Go to /etc and edit php.ini with your favorite editor (I like BBEdit). and add this line:
extension=gettext.so
and search this line in php.ini (VERY IMPORTANT)
extension_dir = "./"
Disable this line if this line is uncommented, just add a semicolon in front of this line.
5. Testing…
Create a phptest.php file with the following code:
<?php
phpinfo();
?>
and save it in /Library/WebServer/Documents.
then, restart Apache and test
Open System Preference → Sharing and check the “web sharing” option
and visit http://127.0.0.1/phptest.php
Bravo!!!!!!!!

If you get this, you get through, well, good luck!








Thanks, good job!
But “tar xzpf php-5.2.4.tar.bz2″ dosn’t work.
you cannot open bz2-files with gzip - so you have to use bzip2
How to:
1. (bzip2 -d php-5.2.4.tar.bz2)
2. (tar xvfpz php-5.2.4.tar)
@ Mrdk
Thank you for pointing out my mistake.
I have modified my command line and I have tested.
it could be like this:
tar xjf php-5.2.4.tar.bz2That was really helpful, thank you very much!
Herzliche Grüße
Thomas
Hello, great guide!! but I ran into a problem. I think I did everything right, but I get the following error in the error_log and gettext is not loading:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gettext.so’ - (null) in Unknown on line 0
what did I do?
[Sun Jan 20 17:46:17 2008] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l PHP/5.2.4 configured — resuming normal operations
Hello,
I too am having this problem:
PHP Warning: PHP Startup: Unable to load dynamic library ‘./gettext.so’ - (null) in Unknown on line 0
[Fri Jan 25 15:54:09 2008] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l PHP/5.2.4 configured — resuming normal operations
The only difference was I placed gettext.so in /usr/lib/php/extensions and kept the extensions_dir = “./” just as a note I did try the suggested way the first time.
Any help would be greatly appreciated.
Thank you
@Nepoc
You have to keep this line (extensions_dir = “./”)enabled?
normally, that you put gettext in /usr/lib/php/extensions will not cause any problem if you disable that line.
I mean, if you disable that line in your php.ini file, system will search gettext.so under /usr/lib/php/extensions. but if you enabled “extensions_dir =”./”", php system will lost its mind. Alex has pointed out that you can customized extension dictionary.
you said you have tried to disable that line the first time, and what kind of error it caused?
Thank you for the response.
Let me explain what I’ve done so far.
When I have ;extensions_dir = “./” and extension=gettext.so in php.ini and /usr/lib/php/extensions/no-debug-non-zts-20060613/gettext.so
When starting web the error_log shows:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gettext.so’ - (null) in Unknown on line 0
[Mon Jan 28 14:34:41 2008] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l PHP/5.2.4 configured — resuming normal operations
When I have extensions_dir = “./” and extension=gettext.so in php.ini and /usr/lib/php/extensions/gettext.so
When starting web the error_log shows:
PHP Warning: PHP Startup: Unable to load dynamic library ‘./gettext.so’ - (null) in Unknown on line 0
[Mon Jan 28 14:42:05 2008] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l PHP/5.2.4 configured — resuming normal operations
I’m assuming it just can’t find the file but I’m not sure.
Let me know if you have any suggestions.
Cheers
Little more info, I tried to rebuild the gettext extension and I have some things that don’t look quite right.
Here’s the output.
There are a few things I thought didn’t look quite right. Mainly all the rm errors.
Hopefully that is helpful to find a solution for me.
@Nepoc
thank you for providing the installation log.
and you can see that configuration stopped at this line:
config.status: config.h is unchangedSo I have a question: Is your machine is 64 bit?
if this is the case, uncompress gettext zip package again and run “make clean” command first. And then check this article http://www.veola.net/macintosh/adding-gd-library-for-mac-os-x-leopard
this article is for installing GD library but the part of the command line for 64 bit is same.
Hey there,
first off thx for the tutorial, unfortunately I fall in a worse case than the one stated above :/
Since I already had libint.h, I started at step 3.
phpize works
configure works
make works
make test fails on both tests (don’t what those tests actually do though…)
make install works (says it copies to [...]/extenions/no-debug-non-zts-20060613)
tried both combinations as Nepoc did (commenting and uncommenting etc.). Apache would start without error message (so I’m thinking hurray), but the phpinfo() function does not show any gettext extension… And for sure it isn’t there cuz my script calling bindtextdomain still doesn’t find it !
Any other clue ?
I can give more info if u need
thx a bunch !
alx
@alx
thank you for your reply, but I don’t know why your php doesn’t run gettext.
phpize works
make works
make test(you don’t need do it)
make install works
and apache works
and i have a question: Did you add this line in your php.ini file?
extension=gettext.soI have the same issue. OS X 10.5 did all the installs for gd library and gettext, everything installed with NO errors, went to the /usr/lib/php/extensions/no-debug-non-zts-20060613/ folder and everything is there.
; Directory in which the loadable extensions (modules) reside.
;extension_dir = “./”
; Enable gd extension module
extension=gd.so
; Enable GetText extension module
extension=gettext.so
Also tried this both ways…
;extension=php_fdf.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_fdf.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
Makes no difference, get NO errors, but neither one shows up in the info.php file….
???
alx and jeremy
have you restarted you apache?
To enable the new configurations,apache must be restarted .
Have the same error. Installation works, apache restarts with no error but neither gd nor gettext shows off in the info.php file also my web applications cannot use it
To get thing to work on 10.5 I had to add the
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load” ./configure
To both the gettext and the php steps.
In my /etc/php.ini I have not commented out the
extensions_dir = “./”
directive.
After a “apachectl restart”, then everything works fine.
I noticed you go right from “make” to “make install” without a “make check.” You have more guts than me, mon ami.
On my Leopard box, for example, gettext compiles without incident, but fails more tests than it passes on a “make check.”
Not working! I don’t know why?
I have a fresh OS X Leopard 10.5.2 install
There is only a php.ini.default but NO php.ini file.
huh?
@scott
There’s no php.ini file by default. so waht you have to do is reanming the php.ini.default to be php.ini
@Richard
yes you are right. I didn’t make check but there’s no issue without doing that step.
This all worked great for me on my MacBook Core 2 Duo (64-bit), but only after I used the longer ./configure mentioned for both gettext and php. I suggest that you modify the original post, because I followed the instructions to the letter and it didn’t work until I found the 64-bit instructions in the comments. Thanks for putting this up, I never would have figured it out.
I just tried these instructions on Leopard (client) and they worked great. I then followed the instructions on Leopard Server and they don’t work. I did everything the same, but I do not get gettext support listed when I do a phpinfo!
Well, I feel like a fool. I was using a 64 bit machine and didn’t realize it.
All is well.