Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a problem with some missing headers when trying to install RODBC in R on my linux. Can anyone help me with this issue?

> 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’
share|improve this question

migrated from stackoverflow.com May 14 '11 at 2:39

This question came from our site for professional and enthusiast programmers.

4 Answers 4

As Dirk said in the comments, if you have already installed r-cran-rodbc, there is no need to run install.packages() from within R. "library(RODBC)" should load the package.

More generally, when you see errors regarding headers, it is because a required development library is not installed. The solution is to search the web using the names of the missing header files (e.g. Google for "sqlext.h ubuntu"), to identify the required package. In this case, you need libiodbc2-dev. So:

sudo apt-get install libiodbc2-dev

Then the install within R should work.

share|improve this answer
1  
FWIW the r-cran-binary is actually built against the other ODBC library in Debian / Ubuntu: unixodbc-dev. –  Dirk Eddelbuettel May 11 '11 at 22:31
    
Do I have to do anything with ODBC driver? –  Jana May 11 '11 at 22:32
1  
Thanks for clarification Dirk; so "sudo apt-get install unixodbc-dev" is an alternative. –  neilfws May 11 '11 at 22:35
    
I followed sudo apt-get install unixodbc-dev and now RODBC is installed and load perfectly in R but when I try to connect to MySQL it says Warning messages: 1: In odbcDriverConnect("Driver={MySQL ODBC 5.1 Driver};Server=10.134.5.62;Database=copy_number;User=root;Password=xxxx;Option=3‌​;") : [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified 2: In odbcDriverConnect("Driver={MySQL ODBC 5.1 Driver};Server=10.134.5.62;Database=copy_number;User=root;Password=xxxx;Option=3‌​;") : ODBC connection failed –  Jana May 11 '11 at 22:40
2  
That's a separate question. But don't ask it: now is the time to go away and read some documentation, tutorials and mailing lists. Then come back with a specific query if you are still stuck. –  neilfws May 12 '11 at 2:59

Do you really need to build from source? Why don't you use the binary package?

So maybe try this instead:

  sudo apt-get install r-cran-rodbc

or use any of the GUI frontends to the package management system.

share|improve this answer
1  
...or follow these instructions in general... –  Joshua Ulrich May 11 '11 at 21:25
    
The r-cran-rodbc package is actually on the Ubuntu repos, and not on the CRAN ones. But that README is still gold. –  Dirk Eddelbuettel May 11 '11 at 21:29
    
I already did this and it said.... Reading package lists... Done Building dependency tree Reading state information... Done r-cran-rodbc is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 22 not upgraded. BUT if I try installing the package in R it says the same error –  Jana May 11 '11 at 21:30
    
So it is installed. So why do you want to install a second copy outside of the package management system? –  Dirk Eddelbuettel May 11 '11 at 21:32
    
Remember it still says.. 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 ... –  Jana May 11 '11 at 21:36

I also had this problem. For me the solution was I was missing some Ubuntu dependencies such as

It's noteworthy that install.packages("RODBC", dependencies=TRUE) does not pick up these packages. They lie outside R itself.

share|improve this answer

FWIW, I had the same problem ("ODBC headers sql.h and sqlext.h not found") on OS X, and fixed it by installing unixodbc (brew install unixodbc)

share|improve this answer
2  
This does not seem to be relevant to the original question in any way. Explaining how uninstalling something with HomeBrew on a OS/X system hardly helps the person struggling with Ubuntu, don't you think? Please take a minute to consider how you could improve your answer and address the problem described in the question. –  Sami Laine May 29 at 8:31
    
os x ? how does installing on osx solve problem of ubuntu –  BlueBerry - vignesh4303 May 29 at 10:20
    
unixodbc exists also for Ubuntu. –  harrymc May 29 at 11:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.