Skip to content

RMySQL : Not loading

3 messages · Geoff Grimwood, Don MacQueen

#
Hello,

I'm tearing my hair out over this. Any help will be very much 
appreciated. It's been two long nights battling with RMySQL.

 > library(RMySQL)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
         unable to load shared library 
"/usr/local/lib/R/library/RMySQL/libs/RMySQL.so":
   dlcompat: dyld: /usr/local/lib/R/bin/R.bin Undefined symbols:
_getopt_long
Error in library(RMySQL) : .First.lib failed

I am running Mac OS 10.2.8, R 1.8.1, RMySQL 0.5-3, MySQL 4.0.17. R and 
MySQL are well otherwise

I have moved away from the Fink sourced (ie /sw) version of R and MySQL 
to regular /usr/local types. Mainly because the Fink R is 1.7 and can't 
do the MySQL business. And I was wondering if the RMySQL install was 
comin to grief because it couldn't find the /sw mysql files.

Anyway, RMySQL seems to have install OK. I see it with 
installed.packages(). There was the apparent inability to find 
lmysqlclient and mysql.h but that seems to be a red herring (see below).

Regards

Geoff Grimwood
Wellington
New Zealand


[SIDLAW02:~/Desktop] geoff% sudo R CMD INSTALL 
--configure-args='--with-mysql-inc=/usr/local/mysql/include 
--with-mysql-lib=/usr/local/mysql/lib' RMySQL_0.5-3.tar.gz
* Installing *source* package 'RMySQL' ...
creating cache ./config.cache
checking how to run the C preprocessor... cc -E
checking for mysql_init in -lmysqlclient... no
checking for mysql.h... no
updating cache ./config.cache
creating ./config.status
creating src/Makevars
** libs
gcc -no-cpp-precomp -I/usr/local/lib/R/include 
-I/usr/local/mysql/include -I/sw/include   -fno-common  -g -O2 -c 
RS-DBI.c -o RS-DBI.o
gcc -no-cpp-precomp -I/usr/local/lib/R/include 
-I/usr/local/mysql/include -I/sw/include   -fno-common  -g -O2 -c 
RS-MySQL.c -o RS-MySQL.o
gcc -bundle -flat_namespace -undefined suppress -L/sw/lib 
-L/usr/local/lib -o RMySQL.so RS-DBI.o RS-MySQL.o 
-L/usr/local/mysql/lib -lmysqlclient -lz -lcc_dynamic 
-L/usr/local/lib/R/bin -lR
[SNIP]

SIDLAW02:library/RMySQL/libs] geoff% ls -ltr
total 500
-rwxr-xr-x    1 root     staff      254816 Jan 14 23:45 RMySQL.so
-rwxr-xr-x    1 root     staff      249856 Jan 14 23:46 libmySQL.dll
-rw-r--r--    1 root     staff         155 Jan 14 23:46 
libMySQL_4.0.16.txt
#
Geoff,

I can offer a work-around.

I have been encountering this same problem on one of two OS X 
systems, and one Solaris system. I've been corresponding with the 
RMySQL maintainer, David James (who I CC'd), and he knows everything 
that I do (and more, of course!). We don't have a proper solution 
yet, but here is a work-around that I found.

To get RMySQL working on the OS X system where it did not, I 
installed the gnugetopt package from fink, and then explicitly told 
RMySQL about it when installing RMySQL. In order to do this you first 
need to have a local copy of the RMySQL distribution file, 
RMySQL_0.5-3.tar.gz. Then, in the directory where that file resides 
define environment variables PKG_CPPFLAGS and PKG_LIBS so that:

    [198]% printenv | grep PKG
    PKG_CPPFLAGS=-I/usr/local/mysql/include -I/sw/include/gnugetopt
    PKG_LIBS=-L/usr/local/mysql/lib -lmysqlclient -lgnugetopt

Then,

R CMD INSTALL --configure-args='--with-mysql-dir=/usr/local/mysql' 
RMySQL_0.5-3.tar.gz

Be sure to replace /usr/local/mysql with whatever is correct for you.

This is only a work-around; there are a number of reasons to believe 
that getopt_long should be present and available when RMySQL is 
installed--but as long as it's not, this is one way to get it.

I have mysql 4.0.16-standard (binary distribution downloaded from 
www.mysql.com),  R 1.8.1 Patched (2004-01-12) (installed from source 
code), and OS X 10.2.8. The gcc is:

[205]% gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1493)



On my other OS X system, where I did not encounter this problem, I'm 
still at R 1.8.0; the mysql is 4.0.15, and it is the version 
distributed by Server Logistics at 
http://www.macintoshhosting.net/mysql.php. That machine is OS X 
10.3.something. I don't have the gcc version information handy.

David James has a successful installation with mysql installed from 
fink in 10.2.8, and R 1.8.1.

I hope this helps; stay tuned as I plan to keep working on this.

-Don
At 12:33 AM +1300 1/15/04, Geoff Grimwood wrote:

  
    
4 days later
#
Any help on this will be greatly appreciated.

Regards

Geoff

Version 1.8.1 Patched (2004-01-15), ISBN 3-900051-00-3

 >   library(RMySQL)
 >   library(DBI)
 >   drv<-dbDriver("MySQL")
 > drv
<MySQLDriver:(5415)>
 > dbConnect(drv,dbname="mysql",user="root",password="******")
Bus error

RMySQL 0.5-3
MySQL is working fine and is 4.0.17
R is fine apart from this
Mac OS 10.2.8, fink, et al (a big et al)

R built using

  ./configure --enable-R-shlib --with-blas=-framework vecLib 
--with-lapack

(It fails to build using ./configure with no options)

RMySQL installed using

setenv PKG_CPPFLAGS '-I/usr/local/mysql/include -I/sw/include/gnugetopt'
setenv PKG_LIBS '-L/usr/local/mysql/lib -lmysqlclient -lgnugetopt'
R CMD INSTALL --configure-args='--with-mysql-dir=/usr/local/mysql' 
RMySQL_0.5-3.tar.gz

[SIDLAW02:~geoff/heaven/src] root# mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
         --cflags         [-I/usr/local/mysql/include -O3 
-fno-omit-frame-pointer]
         --include        [-I/usr/local/mysql/include]
         --libs           [-L/usr/local/mysql/lib -lmysqlclient -lz -lm]
         --libs_r         [-L/usr/local/mysql/lib -lmysqlclient_r -lz 
-lm]
         --socket         [/tmp/mysql.sock]
         --port           [3306]
         --version        [4.0.17]
         --libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -lz -lm]