11

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?

Carl
  • 1,346
  • 15
  • 35
  • Have you tried following the advice from [here](http://stackoverflow.com/a/26219189/324364)? – joran Jan 22 '15 at 05:17
  • Absolutely tried that. The header files required are present and in the PATH. Just that when RStudio builds RODBC it can't find them. – Carl Jan 22 '15 at 05:26
  • Did you try moving the files themselves rather than simply setting the path? – joran Jan 22 '15 at 05:27
  • Yep, they're in `/usr/include`. There is no `libiodbc.a` file in the iODBC source, but I'm thinking one step at a time here. :) Have tried with both iODBC and unixODBC with the same error. – Carl Jan 22 '15 at 05:34
  • Hmm. libiodbc.a was in the source I used, and it worked when I moved all three files. If it still doesn't work after that I don't know what to tell you... – joran Jan 22 '15 at 05:38
  • Ok, have found a previous version of that file, but still the same issue. There is a dynamic library `/usr/lib/libiodbc.dylib` present already though. Do you know of any way to get more verbose debugging from R when it's building a package like this? – Carl Jan 22 '15 at 05:50
  • Nope, sorry. We've reached the limit of what I can help with. You now know exactly what I did to get it to work for me. – joran Jan 22 '15 at 05:54
  • Thanks anyway. I do appreciate it. – Carl Jan 22 '15 at 05:55
  • 3
    `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` from the terminal worked on all our Yosemite systems (R3.1.2, latest Yosemite, latest Xcode/Xcode cmd line tools). I realize that requires Homebrew, but it required no tweaking. – hrbrmstr Jan 22 '15 at 11:35
  • @hrbrmstr well it seemed that worked. I was installing unixODBC using MacPorts and the files were definitely there, but for some reason a homebrew install worked. Thanks heaps! – Carl Jan 22 '15 at 22:19
  • @hrbrmstr, you should post this as an answer so Carl can approve it and I can upvote it. This worked for me too. Muchas gracias. – Don Smith Mar 23 '15 at 11:25
  • Apple chose iODBC over UnixODBC for good reasons. (1) iODBC (albeit outdated) remains part of [macOS High Sierra 10.13.3](https://opensource.apple.com/release/macos-10133.html), as it has been since Panther 10.3.0. (2) Current iODBC, including dylibs, headers, and Frameworks is a [fast & free download & install from iodbc.org](http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/Downloads#Mac_OS_X). – TallTed Apr 02 '18 at 20:00

4 Answers4

22

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.

PatrickR2
  • 13
  • 6
hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
  • I believe that you are a confirmed user of brew and even compile R with it. Do you have any idea whether this works for those of use who are using the CRAN R binaries and hte tools from the r.att.research.com site? – IRTFM Apr 18 '16 at 23:39
  • 1
    it now version 1.3-13 – williamsurles Jul 20 '16 at 16:04
  • 2
    And for some of, we need to `brew install wget` before using this. – Ben Nov 24 '16 at 17:04
  • Your answer was really helpful. Do you know if it's possible to include `RODBC` in a package via packrat or another method such that all recipients of the package won't need to do these steps? – Bobby Nov 25 '16 at 16:38
  • By "in a package", do you mean actually having the `RODBC` package actually be in source tree of another package? It's technically possible and will require some fiddling with the library location paths, but it won't be CRAN-able and leaves you in the position to ensure all `RODBC` updates & fixes get put into your source pkg. – hrbrmstr Nov 25 '16 at 16:52
  • I'm new to packages, but yes that sounds like what I need. I'd like to be able to give the package to my colleagues with all dependencies included such that they can start from a system with only R and R Studio installed and have a minimal amount of setup to do. My work colleagues are not R developers. Can you give me some tips on how to get started with this? – Bobby Nov 26 '16 at 11:37
3

I got a 404 when calling RODBC_1.3-10.tar.gz so I made a tiny change to the script above and it worked perfectly: brew update && brew install unixODBC && wget "http://cran.r-project.org/src/contrib/RODBC_1.3-11.tar.gz" && R CMD INSTALL RODBC_1.3-11.tar.gz

itdnext
  • 73
  • 7
3

I'm using OS X Yosemite 10.10.5, R version 3.2.2. By following below steps, I'm able to make it work.

  1. brew install unixodbc
  2. brew link unixodbc (if missing this step, R still can not find those header files)
  3. install.packages('RODBC', type='source')
Vasfed
  • 18,013
  • 10
  • 47
  • 53
ryan.lan1
  • 31
  • 2
1

On my OS X Yosemite system with unixODBC installed from MacPorts and R 3.3.2, install.packages() failed (whether from repo or from a tarball I had saved locally) but R CMD INSTALL RODBC_1.3-14.tar.gz did the job.

Gabi
  • 1,303
  • 16
  • 20