Link error installing Rcpp "library not found for -lintl"

Apparently, libintl is part of the gettext package. I did the following, possibly redundant reinstall to make sure my copy was up-to-date:

$ brew install gettext
Warning: gettext-0.18.3.2 already installed
$ brew reinstall gettext
==> Reinstalling gettext 
==> Downloading http://ftpmirror.gnu.org/gettext/gettext-0.18.3.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/gettext-0.18.3.2.tar.gz
==> ./configure --prefix=/usr/local/Cellar/gettext/0.18.3.2 --with-included-gettext --with-included-glib --with-included-libcroco --with-included-libunistring --with-emac
==> make
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD gettext library and some software gets confused if both are in the library path.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/gettext/lib
    CPPFLAGS: -I/usr/local/opt/gettext/include

It says in the above output that brew doesn't symlink the library, which might explain why install.packages can't find it. What did the trick was adding a library path into ~/.R/Makevars like so:

PKG_LIBS=-L/usr/local/Cellar/gettext/0.18.3.2/lib

I wanna add my 2 cents to the quest by suggesting a less intrusive (meaning: no files/env changes for the user bringing unwanted side-effects in the future)

Take note of LDFLAGS and CPPFLAGS by reinstalling gettext as @cbare did and pass them to install.packages (inside R) with the configure.args param:

flags="LDFLAGS=-L/usr/local/opt/gettext/lib CPPFLAGS=-I/usr/local/opt/gettext/include"
install.packages('Rcpp', configure.args=flags)

This should do the trick (it worked for me while struggling with the same problem installing Rserve).


This answer is to modify Giupo's answer as it contains a typo but I believe it is important enough to be more prominent than a comment. The solution is a very effective way to install the Rserve package from Homebrew without causing broader problems on OSX:

    flags="CPPFLAGS=-I/usr/local/opt/gettext/lib LDFLAGS=-L/usr/local/opt/gettext/include"
    install.packages('Rserve', configure.args=flags)

To reduce namespace pollution even more can wrap in local:

    local({
           flags="CPPFLAGS=-I/usr/local/opt/gettext/lib LDFLAGS=-L/usr/local/opt/gettext/include"
           install.packages('Rserve', configure.args=flags)})