链接错误安装Rcpp“找不到-lintl的库”

时间:2014-01-26 22:54:28

标签: r homebrew osx-mavericks rcpp

我在尝试安装一些以Rcpp作为依赖项的R软件包时偶然发现了一个链接器错误。我的设置是由Homebrew安装的Mac OS X 10.9.1(Mavericks),R 3.0.2。这是错误输出:

> install.packages('Rcpp')
trying URL 'http://cran.fhcrc.org/src/contrib/Rcpp_0.10.6.tar.gz'
Content type 'application/x-gzip' length 1985569 bytes (1.9 Mb)
opened URL
==================================================
downloaded 1.9 Mb

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c Date.cpp -o Date.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c Module.cpp -o Module.o
clang -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC   -c Rcpp_init.c -o Rcpp_init.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c Timer.cpp -o Timer.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c api.cpp -o api.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c attributes.cpp -o attributes.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c barrier.cpp -o barrier.o
clang++ -I/usr/local/Cellar/r/3.0.2/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fPIC  -g -O2  -c exceptions.cpp -o exceptions.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o Timer.o api.o attributes.o barrier.o exceptions.o -F/usr/local/Cellar/r/3.0.2/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)

4 个答案:

答案 0 :(得分:21)

显然,libintl是gettext包的一部分。我做了以下操作,可能是多余的重新安装,以确保我的副本是最新的:

$ 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

它在上面的输出中说brew没有符号链接库,这可以解释为什么install.packages找不到它。诀窍是将库路径添加到~/.R/Makevars中,如下所示:

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

答案 1 :(得分:5)

这个答案是修改Giupo的答案,因为它包含一个拼写错误,但我认为重要的是要比评论更突出。该解决方案是一种非常有效的方法从Homebrew安装Rserve包,而不会在OSX上引起更广泛的问题:

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

为了减少命名空间污染,更多的东西可以包裹在本地:

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

答案 2 :(得分:4)

我想通过暗示一个不那么具有干扰性的内容来增加我的2美分(意思是:没有文件/环境变化会为用户带来不必要的副作用)

请注意LDFLAGSCPPFLAGS,重新安装gettext作为@cbare,并使用install.packages参数将其传递给configure.args(R内):

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

这应该可以解决问题(在解决安装Rserve的同样问题时,它对我有用。)

答案 3 :(得分:0)

这对我来说很好:

brew link gettext --force