Compiling MySQL-Ruby on Tiger

P

pat allan

Hi all

I've been trying to compile mysql-ruby on MacOS X 10.4 Tiger, but
having no luck.

When I run ruby extconf.rb --with-mysql-dir=/usr/local/mysql:
# ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

... from what I can tell, that's because the mac version of MySQL
doesn't come with libmysqlclient.so - apparently the only way to get
that is to build mysql from source, which i'd like to avoid if
possible.

The install guide also suggests a different flag, --with-mysql-config:
# ruby extconf.rb --with-mysql-config
checking for mysql_ssl_set()... no
checking for mysql.h... yes
creating Makefile

Success? Well, just that step. I then run make, and get the following
output:
# make
gcc -fno-common -arch i386 -arch ppc -g -Os -pipe -fno-common -arch
i386 -arch ppc -pipe -pipe -fno-common -I.
-I/usr/lib/ruby/1.8/powerpc-darwin8.0
-I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_MYSQL_H
-I/usr/local/mysql/include -fno-omit-frame-pointer -c mysql.c
gcc: installation problem, cannot exec 'i686-apple-darwin8-gcc-4.0.0':
No such file or directory
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'
lipo: can't figure out the architecture type of: /var/tmp//ccoPCQRI.out
make: *** [mysql.o] Error 255

'i686' looks strange to me. The version of gcc is 4.0.0 - if I run the
above gcc command with gcc-3.3 it comes up with a single line:
# gcc-3.3 -fno-common -arch i386 -arch ppc -g -Os -pipe -fno-common
-arch i386 -ar ppc -pipe -pipe -fno-common -I.
-I/usr/lib/ruby/1.8/powerpc-darwin8.0
-I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_MYSQL_H
-I/usr/local/mysql/include -fno-omit-frame-pointer -c mysql.c
gcc-3.3: cannot read specs file for arch `i386'

For reference's sake, I'm using MySQL 4.1.11 from the installer at
dev.mysql.org - which is why I'm not trying Ruby-MySQL (since it
doesn't like 4.1.*)

This happens on both 10.4.0 (which I was using last night) and 10.4.1.
I've not used ruby before, but the gems, rake and rails installs were
fine.

Any clues? Or should I just give in and compile mysql from scratch?
 
P

Philipp Kern

pat said:
.. from what I can tell, that's because the mac version of MySQL
doesn't come with libmysqlclient.so - apparently the only way to get
that is to build mysql from source, which i'd like to avoid if
possible.

Well, I did not yet install it here on Tiger, but it would be
libmysqlclientX.dylib instead of .so, try to look for it by using
"mdfind" or "locate".
gcc -fno-common -arch i386 -arch ppc -g -Os -pipe -fno-common -arch
i386 -arch ppc -pipe -pipe -fno-common -I.
[...]
'i686' looks strange to me. The version of gcc is 4.0.0 - if I run the
above gcc command with gcc-3.3 it comes up with a single line:

The hole compiler command seems messed. You really need to kick the
"-arch i386" out of the line.

Kind regards,
Philipp Kern
 
T

ToddG

Possibly avoiding the issue, one workaround might be building your own
ruby 1.8.2 in /usr/local and using that instead of the Apple version. I
haven't tried on Tiger but the build was simple on Panther (./configure
; make; sudo make install), and I've generally had better luck with
self-compiled versions of langs included with OS X (like ruby, python,
etc.)
 
P

Philipp Kern

ToddG said:
[...] and I've generally had better luck with self-compiled
versions of langs included with OS X (like ruby, python, etc.)

The only thing the Ruby build included in Tiger lacks is readline. Sadly
this is really important when one is used to work in the "irb" all the
time. Does anyone know of a solution to this problem?

Kind regards,
Philipp Kern
 
J

Jonathan Weiss

ToddG said:
[...] and I've generally had better luck with self-compiled
versions of langs included with OS X (like ruby, python, etc.)

The only thing the Ruby build included in Tiger lacks is readline. Sadly
this is really important when one is used to work in the "irb" all the
time. Does anyone know of a solution to this problem?

Kind regards,
Philipp Kern

http://tech.rufy.com/entry/46
and
http://blog.innerewut.de/articles/2005/05/08/tiger-and-ruby-readline


Jonathan
 
P

pat allan

Hi Philipp, Todd

There's no file on my machine which starts with libmysqlclient
according to locate, mdfind and spotlight.

And taking -arch i386 out of the compile command removes the i868 error
line, but there's still:
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'

I'll try compiling ruby from scratch (which worked fine on Panther for
me too), and see if that provides a solution.

Thanks for the help :)
 
P

pat allan

Hi Jonathon

I had seen that first link before, but forgot about it until now - but
I've run it anyways (albeit after compiling ruby manually). It doesn't
seem to have made a difference.

Still no luck, same errors as previously described, so I guess the next
step is to follow the link at the bottom of the comments of Lucas
Carlson's post, and install MySQL from DarwinPorts.
 
J

Jim Freeze

* pat allan said:
Hi Jonathon

I had seen that first link before, but forgot about it until now - but
I've run it anyways (albeit after compiling ruby manually). It doesn't
seem to have made a difference.

Still no luck, same errors as previously described, so I guess the next
step is to follow the link at the bottom of the comments of Lucas
Carlson's post, and install MySQL from DarwinPorts.

That readline issue may be a problem with configure.
I have built readline and ruby on OS X and it works fine.
I just recently had to do the same on a Sun and ran
across the this problem: the readline extension did not
build with ruby make, and it should have. So, after
I did ./configure and make, I did:

cd ext/readline
ruby extconfig.rb
make
make install

Then backup up and finished installing ruby:

cd ../..
make install
 
P

pat allan

Hi Jim

When trying to follow your steps:
# ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no

I'm assuming I need at least one yes for it to generate a make file?
Make returns "Nothing to be done for 'all'", too.

And MySQL 4.x through DarwinPorts isn't yet working on Tiger - so that
avenue's closed at the moment. I might try straight from source if I
can be bothered and have the time, or I might just wait till the
DarwinPorts team get their package sorted.
 
E

Ezra Zygmuntowicz

If you install the mysql from http://serverlogistics.com it will work
great on tiger. I got it working with the standard tiger ruiby from
apple. Butf I actually shunned that ruby and compiled my own from
source. But both of them worked with mysql-ruby. The mysql from the
link above also has a sytem preference pane for setting mysql
passwords and stopping and restarting mysqld. Once I installed that
version of mysql the mysql-ruby extension worked fine like this:
$ruby extconf.rb --with-mysql-config
And them make and sudo make install. Hope this helps

-Ezra
 
P

pat allan

Ezra, I thought you'd found the silver bullet, and found the key to
make this all work.

Unfortuantely, the error messages haven't changed at all.

Although considering you have got it working, I must be doing
*something* wrong. Altho I've no idea what. Perhaps its a readline
problem - is there a simple test I can run to confirm whether it is
installed correctly?
 
P

Patrick Gundlach

Hi,
There's no file on my machine which starts with libmysqlclient
according to locate, mdfind and spotlight.

same here.
And taking -arch i386 out of the compile command removes the i868 error
line, but there's still:
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'


It worked for me using 2.5.2
(http://www.tmtm.org/en/mysql/ruby/mysql-ruby-2.5.2.tar.gz) and
typing:

tar xzf mysql-ruby-2.5.2.tar.gz
cd mysql-ruby-2.5.2
ruby extconf.rb --with-mysql-dir=/usr/local/mysql
make
make install


Patrick
 
P

pat allan

Ye gods I think that did it.

Well, with some modifications. I used the --with-mysql-config flag and
the serverlogistics.com version of mysql (I assume you're not using the
default mysql package?). I also had to manually remove the -arch i386
from its two points in the Makefile.

But it has compiled and installed. From one Pat to another, thankyou.
And a massive thanks to all who've provided any input into this thread.
 
P

Patrick Gundlach

Hi,
Well, with some modifications. I used the --with-mysql-config flag and
the serverlogistics.com version of mysql (I assume you're not using the
default mysql package?). I also had to manually remove the -arch i386
from its two points in the Makefile.

I use the one from the mysql site. Don't ask me for the filename, but
it was the 'standard binary distribution for panther', version 4.11.
IIRC. I just installed the pkg, nothing more (and I am using a launchd
xml file instead of the startup script).

But it has compiled and installed. From one Pat to another, thankyou.

You're very welcome.

Patrick
 
J

Jim Freeze

* pat allan said:
Hi Jim

When trying to follow your steps:
# ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no

Ah yes, I left that part out. On Sun I had to install ncurses before
readline. But I thought it was already on OS X. If you
find it on OS X, then set CFLAGS, CPPFLAGS and LDFLAGS
to make sure they have ncurses in their path.
 
R

rom

I might be forking this thread, but I'm having the same problem. I'm
using mySQL 4.1.10 compiled from source via Fink. Don't get me wrong,
if there isn't a fix for this I will definately try the install that
was illustrated earlier using the ServerLogistics install.

I've been hacking at this for about 2 hours, and it just seems too
close to abandon completely. I found the following in the
documentation for mysql-ruby:
" If you get error like 'libmysqlclient not found' when testing, you
need to specify the directory in which the library is located so that
make can find it.
'% env LD_RUN_PATH=libmysqlclient.so directory make'"

I used 'mdfind' to find the libmysqlclient at:
'/sw/lib/mysql/libmysqlclient.14.0.0.dylib'

However, I don't know how to get extconf.rb find it. I'd appreciate
any help with this. I've been working on this so long, I can't see the
forest for the trees, right now. I may not even be grokking the 'env'
command right now...

Thanks!
Pat Allan wrote:
<snip>

I've been trying to compile mysql-ruby on MacOS X 10.4 Tiger, but
having no luck.

When I run ruby extconf.rb --with-mysql-dir=/usr/local/mysql:
# ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

</snip>
 
P

Philipp Kern

rom said:
" If you get error like 'libmysqlclient not found' when testing, you
need to specify the directory in which the library is located so that
make can find it.
'% env LD_RUN_PATH=libmysqlclient.so directory make'"

Actually, if you do not have a specified library in your normal library
path you have to use DYLD_LIBRARY_PATH on OS X. The dynamic linker
settings are prefixed with "DYLD_" instead of the "LD_" on Linux and
perhaps other *nix.

You could try to get "mysql_config" into your path and run "ruby
../extconf.rb --with-mysql-config". It will then run the helper to figure
out any compiler flags. This might help.

Kind regards,
Philipp Kern
 
R

rom

Phillip,

Thanks for the information, and for the help. I did some more looking
around to try and help people who have this problem in the future.

The mysql_config script wasn't on my system.
After I installed the mysql4-dev package from Fink the mysql_config
script was located in "/sw/bin/mysql_config".

So in summary, for those people using Fink to install mysql 4.1.10 you
will need the followng packages:
"mysql" (version 4.1.10-1)
"mysql-client" (version 4.1.10-1)
"mysql4-shlibs" (version 4.1.10-1)
"mysql4-dev" (version 4.1.10-1)

Then you can download and unpack mysql-ruby.
I sucessfully installed mysql-ruby 2.6 running
"sudo ruby extconf.rb --with-mysql-config=/sw/bin/mysql_config"
and then following the rest of the instructions provided by mysql-ruby.

Thanks to everyone on this list who's providing help for this issue. I
hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top