2011-11-30 153 views
2

我試圖在Mac上安裝rpostgresql。我希望能夠使用IP地址連接到服務器,並將數據讀入數據幀。我從CRAN下載的軟件包,跑到下面一行:在Mac OS X 10.7.2上安裝RPostgresql

install.packages('/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz', type='source') 

這開始編譯軟件包,但導致出現以下錯誤信息:

> install.packages('/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz', type='source') 
Installing package(s) into ‘/Library/Frameworks/R.framework/Versions/2.14/Resources/library’ 
(as ‘lib’ is unspecified) 
inferring 'repos = NULL' from the file name 
* installing *source* package ‘RPostgreSQL’ ... 
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked 
checking for gcc... gcc 
checking for C compiler default output file name... a.out 
checking whether the C compiler works... yes 
checking whether we are cross compiling... no 
checking for suffix of executables... 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
checking for pg_config... /usr/bin/pg_config 
checking for "/usr/include/libpq-fe.h"... yes 
configure: creating ./config.status 
config.status: creating src/Makevars 
** libs 
*** arch - x86_64 
gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/include -I/usr/local/include -fPIC -g -O2 -c RS-DBI.c -o RS-DBI.o 
make: gcc-4.2: No such file or directory 
make: *** [RS-DBI.o] Error 1 
ERROR: compilation failed for package ‘RPostgreSQL’ 
* removing ‘/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RPostgreSQL’ 
Warning in install.packages : 
    installation of package ‘/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz’ had non-zero exit status 

我通過諮詢枕着rpostgresql網頁(1,2),但很多建議都超過了一年,所以我認爲可能會有更多關於如何安裝此軟件包的建議。

+0

GCC不再包含在Xcode 4.2,這就是爲什麼失敗。我不確定這種情況下的解決方法是什麼,最好聯繫RPostreSQL開發人員。 –

+0

你確定嗎? http://hints.macworld.com/article.php?story=20110318050811544 –

+0

@DWin GCC不再包含在Xcode中?是。您鏈接的文章也說明了這一點。 –

回答

0

您需要安裝Xcode才能編譯。進入Mac應用商店並搜索,然後安裝Xcode。免費。

你可以通過快速地判斷你是否已經擁有gcc which gcc-4.2。我的猜測是你沒有。安裝Xcode後,您應該得到/usr/bin/gcc-4.2的迴應。

**** ****編輯

你如何安裝Xcode和還沒有GCC-4.2的意見後,我做的閱讀一點點,它看起來像你需要做的這個堆棧溢出問題中列出的選項之一:Setting GCC 4.2 as the default compiler on Mac OS X Leopard

這讓我想知道我的gcc-4.2來自哪裏。我第一次獲得MBP時可能會發生一些偶然事故。

+0

好的。我從應用程序商店安裝了XCode,但沒有安裝gcc,這讓我感到困惑(我記得之前編譯過的東西,但不確定它使用哪個版本的gcc)。我以爲我把它安裝成'哪個gcc'返回'/ usr/bin/gcc';但'哪個gcc-4.2'不會返回任何東西。 – djq

+0

安裝(或重新安裝)Xcode,但哪個gcc-4.2'仍然不返回任何東西。 – djq

+0

嘿等待...我鏈接的東西似乎假設你有gcc-4.2二進制文件...你不這樣做。這似乎是一個問題。 –

1

如果你想連接到一個postgre數據庫,你也可以使用RODBC。只需安裝一個ODBC驅動程序(Lion應該已經包含了postgres),你就可以開始了。 我這樣做是爲了連接到我的本地postgre/postgis服務器,它工作得很好。

0

由於需要postgresql才能從源代碼構建軟件包,因此您需要安裝它。最簡單的方法來做到這一點,如果你使用homebrew,是簡單地在終端中執行以下操作:

## install postgresql 
brew install postgresql 

## install the R package 
Rscript -e "install.packages('RPostgreSQL', type = 'source')" 

## remove postgresql (optional) 
brew remove postgresql