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

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

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

2 Answers

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.

link|improve this answer
...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
show 5 more comments
feedback

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.

link|improve this answer
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
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
show 1 more comment
feedback

Your Answer

 
or
required, but never shown