centos系统R安装RODBC包

在CentOS系统上使用R连接MySQL时,遇到RODBC包安装问题,如no zero exit和缺少mysql.h头文件。解决方法是安装UnixODBC和iodBC驱动。详细步骤包括:1. 安装UnixODBC;2. 安装iodBC;3. 在R环境中安装RODBC。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在centos系统中使用R,连接mysql时,需要RODBC包,直接安装时出现各种错误,

提示no zero exit

 少了mysql.h头文件等,原因是没有安装UnixODBC驱动及ioDBC驱动,

用yum安装之后即可。

1. 安装unixODBC

http://m.blog.youkuaiyun.com/blog/allens_zhou/8575400

2. 安装iodbc

sudo yum install iodbc

3. 进入R,安装RODBC

> install.packages("RODBC")
Installing package into ‘/home/keylab/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
CRAN mirror 

  1: 0-Cloud                        2: Algeria                    
  3: Argentina (La Plata)           4: Australia (Canberra)       
  5: Australia (Melbourne)          6: Austria                    
  7: Belgium                        8: Brazil (BA)                
  9: Brazil (PR)                   10: Brazil (RJ)                
 11: Brazil (SP 1)                 12: Brazil (SP 2)              
 13: Canada (BC)                   14: Canada (NS)                
 15: Canada (ON)                   16: Canada (QC 1)              
 17: Canada (QC 2)                 18: Chile                      
 19: China (Beijing 1)             20: China (Beijing 2)          
 21: China (Beijing 3)             22: China (Beijing 4)          
 23: China (Hefei)                 24: China (Lanzhou)            
 25: China (Xiamen)                26: Colombia (Cali)            
 27: Czech Republic                28: Denmark                    
 29: Ecuador                       30: El Salvador                
 31: Estonia                       32: France (Lyon 1)            
 33: France (Lyon 2)               34: France (Montpellier)       
 35: France (Paris 2)              36: France (Strasbourg)        
 37: Germany (Berlin)              38: Germany (Goettingen)       
 39: Germany (Frankfurt)           40: Germany (Münster)          
 41: Greece                        42: Hungary                    
 43: Iceland                       44: India                      
 45: Indonesia (Jakarta)           46: Indonesia (Jember)         
 47: Iran                          48: Ireland                    
 49: Italy (Milano)                50: Italy (Padua)              
 51: Italy (Palermo)               52: Japan (Tokyo)              
 53: Japan (Tsukuba)               54: Japan (Yamagata)           
 55: Korea (Seoul 1)               56: Korea (Seoul 2)            
 57: Korea (Ulsan)                 58: Lebanon                    
 59: Mexico (Mexico City)          60: Mexico (Texcoco)           
 61: Netherlands (Amsterdam)       62: Netherlands (Utrecht)      
 63: New Zealand                   64: Norway                     
 65: Philippines                   66: Poland                     
 67: Portugal                      68: Russia (Moscow 1)          
 69: Russia (Moscow 2)             70: Singapore                  
 71: Slovakia                      72: South Africa (Johannesburg)
 73: Spain (A Coruña)              74: Spain (Madrid)             
 75: Sweden                        76: Switzerland                
 77: Taiwan (Chungli)              78: Taiwan (Taipei)            
 79: Thailand                      80: Turkey                     
 81: UK (Bristol)                  82: UK (Cambridge)             
 83: UK (Hampshire)                84: UK (London)                
 85: UK (London)                   86: UK (St Andrews)            
 87: USA (CA 1)                    88: USA (CA 2)                 
 89: USA (IA)                      90: USA (IN)                   
 91: USA (KS)                      92: USA (MD)                   
 93: USA (MI 1)                    94: USA (MI 2)                 
 95: USA (MO)                      96: USA (OH 1)                 
 97: USA (OH 2)                    98: USA (OR)                   
 99: USA (PA 1)                   100: USA (PA 2)                 
101: USA (TN)                     102: USA (TX 1)                 
103: USA (WA 1)                   104: USA (WA 2)                 
105: Venezuela                    106: Vietnam                    


Selection: 1
trying URL 'http://cran.rstudio.com/src/contrib/RODBC_1.3-11.tar.gz'
Content type 'application/x-gzip' length 1156962 bytes (1.1 MB)
opened URL
==================================================
downloaded 1.1 MB

* installing *source* package ‘RODBC’ ...
** package ‘RODBC’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -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 -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -m64 -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 -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I. -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c RODBC.c -o RODBC.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o RODBC.so RODBC.o -lodbc -L/usr/lib64/R/lib -lR
installing to /home/keylab/R/x86_64-redhat-linux-gnu-library/3.1/RODBC/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
  converting help for package ‘RODBC’
    finding HTML links ... done
    RODBC-internal                          html  
    RODBC-package                           html  
    odbc                                    html  
    odbcClose                               html  
    odbcConnect                             html  
    odbcDataSources                         html  
    odbcGetInfo                             html  
    odbcSetAutoCommit                       html  
    setSqlTypeInfo                          html  
    sqlColumns                              html  
    sqlCopy                                 html  
    sqlDrop                                 html  
    sqlFetch                                html  
    sqlQuery                                html  
    sqlSave                                 html  
    sqlTables                               html  
    sqlTypeInfo                             html  
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RODBC)

The downloaded source packages are in
	‘/tmp/Rtmp2VAqtB/downloaded_packages’

完成。

遗憾的是,之前的安装错误信息在历史记录中找不到了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值