Easysoft Blog

Wed, 25 April 2018

Using RStudio with a Non-System Version of the unixODBC Driver Manager

By default, RStudio's r-dbi/odbc interface expects to find the unixODBC Driver Manager libraries and include files in a standard location on your system. For example, /usr/lib and /usr/include. If you obtained these libraries and include files by installing a system package, e.g. unixodbc and unixodbc-dev, they will be installed in these standard locations.

If you want to use RStudio with a version of unixODBC that's installed in a non-standard location, you need to set and export PKG_CFLAGS and PKG_LIBS prior to running RStudio. For example, we used these commands to build RStudio's ODBC interface against the unixODBC Driver Manager included with the Easysoft SQL Server ODBC driver distribution. Doing this ensured that both the ODBC driver and ODBC application (r-dbi/odbc) were built against the same version of the Driver Manager:

$ export PKG_CFLAGS="-I/usr/local/easysoft/unixODBC/include"
$ export PKG_LIBS="-lodbc -L/usr/local/easysoft/unixODBC/lib"
$ rstudio &
> Sys.getenv()
_                                   /usr/bin/rstudio
.
.
.
PKG_CFLAGS                          -I/usr/local/easysoft/unixODBC/include
PKG_LIBS                            -lodbc -L/usr/local/easysoft/unixODBC/lib
> install.packages("odbc")