Problem with RODBC installation in Ubuntu with R 3.5.1

The thread here about RODBC is old, about 7 years old, their solution about installing r-cran-odbc and libiodbc2-dev do not work. As of R 3.5.1, I am getting the same error as 7 years ago

install.packages("RODBC", keep_outputs = T)
configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/opt/conda/lib/R/library/RODBC’

despite having the mentioned packages installed. So

How to get the RODBC installed in Ubuntu as of R 3.5.1 (latest versions of R and Ubuntu)?


Minimal reproducible base (Dockerfile)

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <>"
USER root
# R pre-requisites
RUN apt-get update && \ apt-get install -y --no-install-recommends \ fonts-dejavu \ tzdata \ libiodbc2-dev \ r-cran-rodbc \ gfortran \ gcc && \ rm -rf /var/lib/apt/lists/*
USER $NB_UID
# R packages
RUN conda install --quiet --yes \ 'r-base=3.5.1' \ 'r-irkernel=0.8*' \ 'r-plyr=1.8*' \ 'r-devtools=1.13*' \ 'r-tidyverse=1.2*' \ 'r-shiny=1.2*' \ 'r-rmarkdown=1.11*' \ 'r-forecast=8.2*' \ 'r-rsqlite=2.1*' \ 'r-reshape2=1.4*' \ 'r-nycflights13=1.0*' \ 'r-caret=6.0*' \ 'r-rcurl=1.95*' \ 'r-crayon=1.3*' \ 'r-randomforest=4.6*' \ 'r-htmltools=0.3*' \ 'r-sparklyr=0.9*' \ 'r-htmlwidgets=1.2*' \ 'r-hexbin=1.27*' && \ conda clean -tipsy && \ fix-permissions $CONDA_DIR

where the following packages libiodbc2-dev and r-cran-rodbc won't resolve the issue.

Specs

$ uname -a
Linux 370485a13e40 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

sql.h is located in the following

$ apt-file sql.h
libdballe-dev: /usr/include/dballe/sql/sql.h
libiodbc2-dev: /usr/include/iodbc/sql.h
libmailutils-dev: /usr/include/mailutils/sql.h
libwine-dev: /usr/include/wine/windows/sql.h
libwine-development-dev: /usr/include/wine-development/wine/windows/sql.h
mingw-w64-common: /usr/share/mingw-w64/include/sql.h
mingw-w64-i686-dev: /usr/i686-w64-mingw32/include/sql.h
mingw-w64-x86-64-dev: /usr/x86_64-w64-mingw32/include/sql.h
pike7.8-core: /usr/lib/pike7.8/include/sql.h
pike8.0-core: /usr/lib/pike8.0/include/sql.h
unixodbc-dev: /usr/include/sql.h

and

# apt-file search /sqlext.h
libiodbc2-dev: /usr/include/iodbc/sqlext.h
libwine-dev: /usr/include/wine/windows/sqlext.h
libwine-development-dev: /usr/include/wine-development/wine/windows/sqlext.h
mingw-w64-common: /usr/share/mingw-w64/include/sqlext.h
mingw-w64-i686-dev: /usr/i686-w64-mingw32/include/sqlext.h
mingw-w64-x86-64-dev: /usr/x86_64-w64-mingw32/include/sqlext.h
unixodbc-dev: /usr/include/sqlext.h
1

1 Answer

The missing headers problem can be solved by installing the r-rodbc package from conda such that

RUN conda install --quiet --yes \ 'r-base=3.5.1' \ 'r-rodbc=1.3*' \

and then after that you will get the following error

hecking for library containing SQLTables... no
configure: error: "no ODBC driver manager found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/opt/conda/lib/R/library/RODBC’
* restoring previous ‘/opt/conda/lib/R/library/RODBC’

for which you need r-cran-odbc, unixodbc and 'unixodbc-dev' (just unixodbc is not enough) from apt so your Dockerfile becomes

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <>"
USER root
# R pre-requisites
RUN apt-get update && \ apt-get install -y --no-install-recommends \ fonts-dejavu \ tzdata \ unixodbc \ unixodbc-dev \ r-cran-rodbc \ gfortran \ gcc && \ rm -rf /var/lib/apt/lists/*
USER $NB_UID
# R packages
RUN conda install --quiet --yes \ 'r-base=3.5.1' \ 'r-rodbc=1.3*' \ 'unixodbc=2.3.*' \ 'r-irkernel=0.8*' \ 'r-plyr=1.8*' \ 'r-devtools=1.13*' \ 'r-tidyverse=1.2*' \ 'r-shiny=1.2*' \ 'r-rmarkdown=1.11*' \ 'r-forecast=8.2*' \ 'r-rsqlite=2.1*' \ 'r-reshape2=1.4*' \ 'r-nycflights13=1.0*' \ 'r-caret=6.0*' \ 'r-rcurl=1.95*' \ 'r-crayon=1.3*' \ 'r-randomforest=4.6*' \ 'r-htmltools=0.3*' \ 'r-sparklyr=0.9*' \ 'r-htmlwidgets=1.2*' \ 'r-hexbin=1.27*' && \ conda clean -tipsy && \ fix-permissions $CONDA_DIR

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like