问题描述
尝试在Linux上的R中安装RODBC时,出现一些标题丢失的问题。谁能帮我解决这个问题?
> install.packages("RODBC")
Installing package(s) into ‘/home/administrator/R/x86_64-pc-linux-gnu-library/2.12’
(as ‘lib’ is unspecified)
trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/RODBC_1.3-2.tar.gz'
Content type 'application/x-gzip' length 1108358 bytes (1.1 Mb)
opened URL
==================================================
downloaded 1.1 Mb
* installing *source* package ‘RODBC’ ...
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 ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking sqlext.h usability... no
checking sqlext.h presence... no
checking for sqlext.h... no
configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/home/administrator/R/x86_64-pc-linux-gnu-library/2.12/RODBC’
Warning in install.packages :
installation of package 'RODBC' had non-zero exit status
The downloaded packages are in
‘/tmp/RtmpqfNYpD/downloaded_packages’
最佳回答
正如Dirk在评论中所说,如果您已经安装了r-cran-rodbc,则无需从R内部运行install.packages()。”library(RODBC)”应该加载该软件包。
通常,当您看到有关标题的错误时,这是因为未安装必需的开发库。解决方案是使用缺少的头文件名搜索网络(例如Google的“ sqlext.h ubuntu”),以识别所需的程序包。在这种情况下,您需要libiodbc2-dev。所以:
sudo apt-get install libiodbc2-dev
然后,在R中进行安装即可。
次佳回答
尝试从该站点以及其他站点上的所有解决方案安装软件包之后,我成功使用以下方法构建了RODBC
软件包:
sudo apt-get install unixodbc unixodbc-dev
我还安装了:
-
libiodbc2-dev
-
libmyodbc
-
odbc-postgresql
第三种回答
您真的需要从源代码构建吗?为什么不使用二进制包?
因此,也许尝试以下方法:
sudo apt-get install r-cran-rodbc
或使用软件包管理系统的任何GUI前端。
第四种回答
FWIW,我在OS X上遇到了相同的问题(“找不到ODBC标头sql.h和sqlext.h”),并通过安装unixodbc(brew install unixodbc
)进行了修复。