problem with RODBC installation in Ubuntu

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’

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.


After attempting to install packages from all the solutions on this site and others, I was successful in building the RODBC package using:

sudo apt-get install unixodbc unixodbc-dev

I also installed:

  • libiodbc2-dev
  • libmyodbc
  • odbc-postgresql

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.


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)