2014-01-26 60 views
9

我試圖安裝一些R作爲依賴關係的R包時偶然發現了一個鏈接器錯誤。我的設置是由Homebrew安裝的Mac OS X 10.9.1(Mavericks),R 3.0.2。下面是錯誤輸出:鏈接錯誤安裝Rcpp「找不到-lintl的庫」

> 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) 

回答

18

顯然,的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 

它說,在醞釀不符號鏈接庫,上面的輸出這或許可以解釋爲什麼install.packages不能找到它。什麼做的伎倆被添加庫路徑爲~/.R/Makevars像這樣:

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

這在我看來是一個有點不尋常。你是從源碼構建R還是使用Simon的二進制文件? –

+0

通過自制軟件安裝R。 – cbare

+2

官方的話是不支持的。如果你走這條路,事情就會破裂,你就會保留這兩件東西。也許試試'r-sig-mac'列表? –

4

我想通過暗示干擾性較低(意味着加我2美分,收於追求:沒有文件/用戶ENV變化帶來不必要的副作用在未來的影響)

注意到LDFLAGSCPPFLAGS通過與configure.args PARAM重新安裝的gettext作爲@cbare做並傳遞給install.packages(內部R):

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

ŧ他應該做的伎倆(它爲我工作,同時安裝Rserve同樣的問題掙扎)。

+1

希望任何想使用Homebrew的人都會看到這個解決方案,因爲它的工作原理和最小的副作用 – mcheema

+0

我不明白,brew顯示 'LDFLAGS:-L/usr/local/opt/gettext/lib CPPFLAGS :-I/usr/local/opt/gettext/include' 但你似乎讓它們互換? – rien333

2

這個答案是修改Giupo的答案,因爲它包含了一個錯字,但我相信它比評論更重要。解決的辦法是安裝從自制的Rserve包,而不會對OSX更廣泛的問題非常有效的方法:

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

要減少命名空間的污染更是可以在本地包裝:

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

我嘗試編輯較早的問題,但神祕地編輯拒絕。 – mcheema