1. 场景描述
R语言 3.2, Ubuntu 15.10, 根据情况需要安装RODBC。 故执行命令:
install.packages('RODBC')报错信息如下:
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/bladestone/R/x86_64-pc-linux-gnu-library/3.2/RODBC’
Warning in install.packages :
installation of package ‘RODBC’ had non-zero exit status
error: "ODBC headers sql.h and sqlext.h not found"2. 问题分析
ODBC是什么? ODBC是一套连接数据库的访问协议,如果有和它相关的内容没有找到或者有问题,是否可以定位为ODBC本身在当前主机上的驱动或者类库有问题?
3. 系统检查
Ubuntu上的与ODBC相关的内容是unixODBC,故可以检查一下这问题
执行命令:
dpkg -s unixODBC结果发现, unixODBC已经安装,而dev版本未安装, 问题定位确认。
dpkg -s unixODBC-dev
那有同学就会问题了? unixODBC不是已经安装了吗,为什么还需要dev版本呢? 一般而言,如果基于源代码包来编译进行安装的情况,都是需要一定的依赖包,也就说发布包是基于二进制和特定操作系统来生成的,但是由于操作系统以及依赖环境的差异性,顺利安装的概率优先,很多情况下都是缺少依赖就无法正确安装。 所以大部分情况下都是基于源代码来编译安装的,R这里就是这种情况。
dev版本一般就是为了进行基于源代码编译然后安装的情况而生成的。
4. 问题解决
安装依赖包
sudo apt-get insall unixODBC-dev
安装RODBC
install.packages('RODBC')
安装结果信息:
> install.packages('RODBC')5. R安装过程信息的分析
Installing package into ‘/home/bladestone/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
--2016-03-24 07:02:18-- https://cran.rstudio.com/src/contrib/RODBC_1.3-12.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 204.246.164.132
Connecting to cran.rstudio.com (cran.rstudio.com)|204.246.164.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1157460 (1.1M) [application/x-gzip]
Saving to: ‘/tmp/RtmpUoOP9e/downloaded_packages/RODBC_1.3-12.tar.gz’
0K .......... .......... .......... .......... .......... 4% 146K 7s
50K .......... .......... .......... .......... .......... 8% 166K 7s
100K .......... .......... .......... .......... .......... 13% 189K 6s
150K .......... .......... .......... .......... .......... 17% 167K 6s
200K .......... .......... .......... .......... .......... 22% 12.2M 4s
250K .......... .......... .......... .......... .......... 26% 11.7M 3s
300K .......... .......... .......... .......... .......... 30% 170K 3s
350K .......... .......... .......... .......... .......... 35% 8.82M 3s
400K .......... .......... .......... .......... .......... 39% 11.4M 2s
450K .......... .......... .......... .......... .......... 44% 11.9M 2s
500K .......... .......... .......... .......... .......... 48% 175K 2s
550K .......... .......... .......... .......... .......... 53% 11.9M 2s
600K .......... .......... .......... .......... .......... 57% 11.8M 1s
650K .......... .......... .......... .......... .......... 61% 11.4M 1s
700K .......... .......... .......... .......... .......... 66% 11.8M 1s
750K .......... .......... .......... .......... .......... 70% 8.72M 1s
800K .......... .......... .......... .......... .......... 75% 11.5M 1s
850K .......... .......... .......... .......... .......... 79% 2.82M 0s
900K .......... .......... .......... .......... .......... 84% 191K 0s
950K .......... .......... .......... .......... .......... 88% 11.4M 0s
1000K .......... .......... .......... .......... .......... 92% 11.6M 0s
1050K .......... .......... .......... .......... .......... 97% 11.8M 0s
1100K .......... .......... .......... 100% 12.6M=2.1s
2016-03-24 07:02:22 (531 KB/s) - ‘/tmp/RtmpUoOP9e/downloaded_packages/RODBC_1.3-12.tar.gz’ saved [1157460/1157460]
* installing *source* package ‘RODBC’ ...
** package ‘RODBC’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
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 -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -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... yes
checking sql.h presence... yes
checking for sql.h... yes
checking sqlext.h usability... yes
checking sqlext.h presence... yes
checking for sqlext.h... yes
checking for library containing SQLTables... -lodbc
checking for SQLLEN... yes
checking for SQLULEN... yes
checking for long... yes
checking size of long... 8
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/config.h
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RODBC.c -o RODBC.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RODBC.so RODBC.o -lodbc -L/usr/lib/R/lib -lR
installing to /home/bladestone/R/x86_64-pc-linux-gnu-library/3.2/RODBC/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RODBC)
The downloaded source packages are in
‘/tmp/RtmpUoOP9e/downloaded_packages’
经过观察可以发现,其中有checking,configure, gcc之类的中间信息出来,这些都是基于Linux的make命令而来的编译安装过程,基于这些信息,就基本可以确定这个是基于源代码来进行安装的。