Installation of RODBC on OS X Yosemite

Carl picture Carl · Jan 22, 2015 · Viewed 8.5k times · Source

When installing the R package RODBC in RStudio on OS X Yosemite, I get the following error:

configure: error: "ODBC headers sql.h and sqlext.h not found"

This is a common error and indicates that ODBC drivers haven't been installed (iODBC headers aren't included in OS 10.9 hence the separate install required). So, I install unixODBC and confirm that the header files are present in the PATH.

Sys.getenv("PATH") gives me the correct path including where the two files are found.

However, when I try install.packages("RODBC",type = "source") again, the same error persists. Have tested this with iODBC as well as unixODBC.

Are there any other tests I can perform to help diagnose the issue?

Answer

hrbrmstr picture hrbrmstr · Mar 23, 2015

We have a bunch of Yosemite systems with R 3.1.2 that are all up-to-date with Xcode & Xcode command-line tools. The following consistently works with each major R update or new system install (at the Terminal):

brew update && brew install unixODBC && \
  wget "http://cran.r-project.org/src/contrib/RODBC_1.3-10.tar.gz" && \
  R CMD INSTALL RODBC_1.3-10.tar.gz 

It (obviously) requires Homebrew, but that's what we've standardized on in our shop.

As RODBC is updated, the version number (1.3-10, 1.3-11, ...) will change. To find out the current version, look at https://cran.r-project.org/web/packages/RODBC/index.html.