Skip to content

[R-pkg-devel] Debugging RODBC installation problems on FreeBSD (unixodbc library path)

4 messages · Dirk Eddelbuettel, Rasmus Liland

#
Dear r-package-devel list subscribers,

can someone please guide me a little in
installing RODBC[1] on FreeBSD 13?

I believe it depends on unixodbc[2], but
the compilation stops with at not
finding unixodbc (I think):

	rasmus at iselin ~ % mkdir ~/src/RODBC
	rasmus at iselin ~ % cd ~/src/RODBC
	rasmus at iselin ~/src/RODBC % fetch 'https://cran.rstudio.com/src/contrib/RODBC_1.3-17.tar.gz'
	rasmus at iselin ~/src/RODBC % R CMD INSTALL RODBC
	* installing to library ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0?
	* installing *source* package ?RODBC? ...
	** package ?RODBC? successfully unpacked and MD5 sums checked
	** using staged installation
	checking for gcc... cc
	checking whether the C compiler works... yes
	checking for C compiler default output file name... a.out
	checking for suffix of executables...
	checking whether we are cross compiling... no
	checking for suffix of object files... o
	checking whether we are using the GNU C compiler... yes
	checking whether cc accepts -g... yes
	checking for cc option to accept ISO C89... none needed
	checking how to run the C preprocessor... cc -E
	checking for grep that handles long lines and -e... /usr/bin/grep
	checking for egrep... /usr/bin/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... yes
	checking sql.h presence... yes
	checking for sql.h... yes
	checking sqlext.h usability... yes
	checking sqlext.h presence... yes
	checking for sqlext.h... yes
	checking for library containing SQLTables... no
	configure: error: "no ODBC driver manager found"
	ERROR: configuration failed for package ?RODBC?
	* removing ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0/RODBC?

I've attached the config.log.  I think
the important lines are 249:253:

	configure:3672: cc -o conftest -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -I.  conftest.c -lodbc   >&5
	ld: error: unable to find library -lodbc
	cc: error: linker command failed with exit code 1 (use -v to see invocation)
	configure:3672: $? = 1

I found line 48 in configure.ac [3]

	odbc_lib_path=`odbc_config --libs | sed s/-lodbc//`

and tried to change it to

	odbc_lib_path=`pkg-config --libs --cflags odbc | sed s/-lodbc//`

but this changes nothing (I think ...)

Running odbc_config and pkg-config:

	rasmus at iselin ~/src/RODBC % odbc_config --libs
	-L/usr/local/lib -lodbc
	rasmus at iselin ~/src/RODBC % pkg-config --libs --cflags odbc
	-I/usr/local/include -L/usr/local/lib -lodbc

Hey, I am at a loss here ...

I have not done much debugging work like 
this before ...

Perhaps some kind soul among you can 
provide some useful pointers on this?

Best,
Rasmus Liland

[1] https://cran.r-project.org/web/packages/RODBC/index.html
[2] http://www.unixodbc.org/
[3] https://raw.githubusercontent.com/cran/RODBC/master/configure.ac

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: config.log
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20210329/688d058f/attachment.log>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20210329/688d058f/attachment.sig>
#
On 29 March 2021 at 23:29, Rasmus Liland wrote:
| can someone please guide me a little in
| installing RODBC[1] on FreeBSD 13?
| 
| I believe it depends on unixodbc[2], but
| the compilation stops with at not
| finding unixodbc (I think):
| 
| 	rasmus at iselin ~ % mkdir ~/src/RODBC
| 	rasmus at iselin ~ % cd ~/src/RODBC
| 	rasmus at iselin ~/src/RODBC % fetch 'https://cran.rstudio.com/src/contrib/RODBC_1.3-17.tar.gz'
| 	rasmus at iselin ~/src/RODBC % R CMD INSTALL RODBC
| 	* installing to library ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0?
[...]
| 	checking for sqlext.h... yes
| 	checking for library containing SQLTables... no
| 	configure: error: "no ODBC driver manager found"
| 	ERROR: configuration failed for package ?RODBC?
| 	* removing ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0/RODBC?
| 
| I've attached the config.log.  I think
| the important lines are 249:253:

I find it easier to look at the input code in configure.ac that is used to
create configure (which, as a machine generated script, is less readable,
same for the log). So we see that test for sqlext.h still passed, but the
next one failed. Using the source for RODBC we have first the block that
passes and then the block that fails:

   dnl Check the headers can be found
   AC_CHECK_HEADERS(sql.h sqlext.h)
   if test "${ac_cv_header_sql_h}" = no || 
      test "${ac_cv_header_sqlext_h}" = no; then
      AC_MSG_ERROR("ODBC headers sql.h and sqlext.h not found")
   fi
   
   dnl search for a library containing an ODBC function
   if test [ -n "${odbc_mgr}" ] ; then
     AC_SEARCH_LIBS(SQLTables, ${odbc_mgr}, ,
   	         AC_MSG_ERROR("ODBC driver manager '${odbc_mgr}' not found"))
   else
     AC_SEARCH_LIBS(SQLTables, odbc odbc32 iodbc, ,
   	         AC_MSG_ERROR("no ODBC driver manager found"))
   fi
   
So we see that we end up in the else branch of the test for
odbc_mgr. Scrolling back we see

   dnl A user-specifiable option
   odbc_mgr=""
   AC_ARG_WITH([odbc-manager],
               AC_HELP_STRING([--with-odbc-manager=MGR],
                              [specify the ODBC manager, e.g. odbc or iodbc]),
               [odbc_mgr=$withval])
   
   if test "$odbc_mgr" = "odbc" ; then
     AC_PATH_PROGS(ODBC_CONFIG, odbc_config)
   fi

So this wants you to specify either (unix)odbc or (lib)iodbc explicitly, and
if odbc was set, check for odbc_config.

I have looked after RODBC for Debian since 2003 or so, and I think I switched
from unixodbc to iodbc and back in that time, reflecting the state of the
library at the time. I think what I would do now is to see which of libiodbc
and unixodbc is present, and if it is the latter if setting it as argument to
--with-odbc-manager helps some more.

Dirk
#
Dirk, I did not realize libiodbc[1] is an 
alternative to unixODBC, how are you 
able to see this?  

I also did not realize I had both of 
them installed ... 

Uninstalling libiodbc, keeping unixODBC, 
adding the flag (I only suppose this is 
how the flag is added), does nothing:

	rasmus at iselin ~/src/RODBC % R CMD INSTALL RODBC --with-odbc-manager=odbc
	Warning: unknown option ?--with-odbc-manager=odbc?
	* installing to library ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0?
	* installing *source* package ?RODBC? ...
	files ?configure?, ?configure.ac? have the wrong MD5 checksums
	** using staged installation
	checking for gcc... cc
	checking whether the C compiler works... yes
	checking for C compiler default output file name... a.out
	checking for suffix of executables...
	checking whether we are cross compiling... no
	checking for suffix of object files... o
	checking whether we are using the GNU C compiler... yes
	checking whether cc accepts -g... yes
	checking for cc option to accept ISO C89... none needed
	checking how to run the C preprocessor... cc -E
	checking for grep that handles long lines and -e... /usr/bin/grep
	checking for egrep... /usr/bin/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... yes
	checking sql.h presence... yes
	checking for sql.h... yes
	checking sqlext.h usability... yes
	checking sqlext.h presence... yes
	checking for sqlext.h... yes
	checking for library containing SQLTables... no
	configure: error: "no ODBC driver manager found"
	ERROR: configuration failed for package ?RODBC?
	* removing ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0/RODBC?

The other way around, uninstalling 
unixODBC, keeping libiodbc, brings me 
one step backwards: 

	rasmus at iselin ~/src/RODBC % R CMD INSTALL RODBC --with-odbc-manager=iodbc
	Warning: unknown option ?--with-odbc-manager=iodbc?
	* installing to library ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0?
	* installing *source* package ?RODBC? ...
	files ?configure?, ?configure.ac? have the wrong MD5 checksums
	** using staged installation
	checking for gcc... cc
	checking whether the C compiler works... yes
	checking for C compiler default output file name... a.out
	checking for suffix of executables...
	checking whether we are cross compiling... no
	checking for suffix of object files... o
	checking whether we are using the GNU C compiler... yes
	checking whether cc accepts -g... yes
	checking for cc option to accept ISO C89... none needed
	checking how to run the C preprocessor... cc -E
	checking for grep that handles long lines and -e... /usr/bin/grep
	checking for egrep... /usr/bin/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 ?/usr/home/rasmus/R/amd64-portbld-freebsd13.0-library/4.0/RODBC?

... the sql.h and sqlext.h header files 
are there, libiodbc provides them both:

	root at iselin /usr/home/rasmus # pkg info -l libiodbc | egrep 'sql.h|sqlext.h'
	        /usr/local/include/libiodbc/isql.h
	        /usr/local/include/libiodbc/isqlext.h
	        /usr/local/include/libiodbc/sql.h
	        /usr/local/include/libiodbc/sqlext.h

... also when having unixodbc installed:

	root at iselin /usr/home/rasmus # pkg info -l unixODBC-2.3.9 | egrep 'sql.h|sqlext.h'
	        /usr/local/include/sql.h
	        /usr/local/include/sqlext.h

Rasmus

[1] https://www.freshports.org/databases/libiodbc/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20210330/60b98b81/attachment.sig>
#
On 30 March 2021 at 01:10, Rasmus Liland wrote:
| Dirk, I did not realize libiodbc[1] is an 
| alternative to unixODBC, how are you 
| able to see this?  

By studing the sources and README of the package you are trying to build.
 
| I also did not realize I had both of 
| them installed ... 
| 
| Uninstalling libiodbc, keeping unixODBC, 
| adding the flag (I only suppose this is 
| how the flag is added), does nothing:
| 
| 	rasmus at iselin ~/src/RODBC % R CMD INSTALL RODBC --with-odbc-manager=odbc
| 	Warning: unknown option ?--with-odbc-manager=odbc?
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

These runs are not doing what you think they are doing.  The switch applies
to calling 'configure' directly (which I recommend you do for debugging). For
builds from 'R CMD INSTALL ...' you need another indirection, see --help there.

If I were you, I'd try to mimick what 'configure' does and compile and link a
minimal C program against either of the two to demonstrate "you can". The
next step then is to make 'configure' do it too, ideally without switches.
Then the R package has a better-than-fair chance of installing.

Dirk