'How to install gettext on MacOS X
How do I install gettext on mac?
I get this error on one of my php pages:
Fatal error: Call to undefined function bindtextdomain()
and it's because I don't have gettext installed.
I can't find good instructions on how to install it. I've tried using:
brew install gettext
and it puts some files here:
/usr/local/Cellar/gettext/0.18.2
but I don't know what to do with that.
Update: Instead of trying to use homebrew, now I tried this method unsucessfully using wget:
Download with wget
cd ~/Downloads
wget http://ftp.gnu.org/gnu/gettext/gettext-0.18.2.tar.gz
tar -zxvf gettext-0.18.2.tar.gz
cd gettext-0.18.2
./configure
make
make check is optional to run self-tests
make check
Errors I got:
make[3]: *** [check-TESTS] Error 1
make[2]: *** [check-am] Error 2
make[1]: *** [check-recursive] Error 1
sudo make install
That installs it here: /usr/local/share/gettext
And the documentation here: /usr/local/share/doc/gettext
but how do I make my php pages be able to use gettext and the bindtextdomain() function?
Solution 1:[1]
You can use brew to link gettext after installing it
brew install gettext
brew link --force gettext
Solution 2:[2]
I found an easiest working solution, which still works on mavericks. Here it is: https://stackoverflow.com/a/11792640/512504
Solution 3:[3]
If reinstall php is acceptable, try to download and install the php version you want from here.
In my case, I used 7.0 version. Steps to reinstall:
- Open terminal and run
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0 The installed php will reside at
/usr/local/php5-7.0.31-20180903-120321/lib(I'm not sure why the directory name is php5-7xxxx, but the installed php version is 7.0)Edit apache2 config at
/private/etc/apache2/httpd.conf(make a backup if necessary)Replace
LoadModule php7_module libexec/apache2/libphp7.sowithLoadModule php7_module /usr/local/php5-7.0.31-20180903-120321/libphp7.so(remember to uncomment the "#" symbol), then save and exit.Finally, run
apachectl restartto restart your apache server.
Solution 4:[4]
Posting alternative way, without homebrew:
cd /tmp
# Download with curl, as it is available by default, without brew
$ curl -O https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.gz
# Extract and cd into created directory
$ tar xvfz gettext-0.20.1.tar.gz && cd gettext-0.20.1
# Configure sources
$ ./configure --prefix=/usr/local/gettext/0_20_1 \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-debug \
--disable-java \
--disable-csharp \
--without-git \
--without-cvs \
--without-xz \
--with-included-gettext
# Comile
$ make
# Install to system
$ sudo make install
Linking all libs:
#!/bin/bash
### /usr/local/bin
ln -s /usr/local/gettext/0_20_1/bin/autopoint /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/envsubst /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/gettext /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/gettextize /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/gettext.sh /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgattrib /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgcat /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgcmp /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgcomm /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgconv /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgen /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgexec /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgfilter /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgfmt /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msggrep /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msginit /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgmerge /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msgunfmt /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/msguniq /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/ngettext /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/recode-sr-latin /usr/local/bin/
ln -s /usr/local/gettext/0_20_1/bin/xgettext /usr/local/bin/
### /usr/local/include
ln -s /usr/local/gettext/0_20_1/include/autosprintf.h /usr/local/include/
ln -s /usr/local/gettext/0_20_1/include/gettext-po.h /usr/local/include/
ln -s /usr/local/gettext/0_20_1/include/textstyle /usr/local/include/
ln -s /usr/local/gettext/0_20_1/include/textstyle.h /usr/local/include/
### /usr/local/lib
ln -s /usr/local/gettext/0_20_1/lib/gettext /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libasprintf.a /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libasprintf.la /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libasprintf.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libasprintf.so.0 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libasprintf.so.0.0.0 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextlib-0.20.1.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextlib.la /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextlib.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextpo.a /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextpo.la /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextpo.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextpo.so.0 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextpo.so.0.5.5 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextsrc-0.20.1.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextsrc.la /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libgettextsrc.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libtextstyle.a /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libtextstyle.la /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libtextstyle.so /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libtextstyle.so.0 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/libtextstyle.so.0.0.0 /usr/local/lib/
ln -s /usr/local/gettext/0_20_1/lib/preloadable_libintl.so /usr/local/lib/
### /usr/local/share/aclocal
ln -s /usr/local/gettext/0_20_1/share/aclocal/gettext.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/host-cpu-c-abi.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/iconv.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/intlmacosx.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/lib-ld.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/lib-link.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/lib-prefix.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/nls.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/po.m4 /usr/local/share/aclocal/
ln -s /usr/local/gettext/0_20_1/share/aclocal/progtest.m4 /usr/local/share/aclocal/
Add to your ~/.bashrc or ~/.zshrc:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export ACLOCAL_PATH=/usr/local/share/aclocal/:$ACLOCAL_PATH
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gabriele Petronella |
| Solution 2 | Community |
| Solution 3 | |
| Solution 4 | user991 |

