Problem building mysql-ruby under 1.8.0

$ pwd
/home/brian/work/mysql-ruby-2.4.4
$ ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… yes
checking for mysql.h… yes
creating Makefile
extconf.rb:33: uninitialized constant CPP (NameError)

Line 33 says:

cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)

It seems this was defined in ruby-1.6.8:
$ ruby16 -v -rmkmf -e 'p CPP’
ruby 1.6.8 (2002-12-24) [i386-freebsd4.7]
“gcc -E -E %s -I$(rubylibdir)/$(arch) -g -O2 %s %s conftest.c”

Anybody know what I should change this to?

Thanks,

Brian.

cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, '')

Can you try ?

     Config::expand(cpp_command(""))

Guy Decoux

[courtesy cc of this posting sent to cited author via email]

In article 20030804144606.A30641@linnet.org,

cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)

The following, taken from the FreeBSD port works:

— extconf.rb.orig Wed Jan 29 08:59:59 2003
+++ extconf.rb Wed Jan 29 19:02:41 2003
@@ -24,13 +24,18 @@
else
exit 1
end
+$objs = [“mysql.o”]
create_makefile(“mysql”)

make mysql constant

File::open(“conftest.c”, “w”) do |f|
f.puts src
end
-cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)
+if defined? cpp_command

  • cpp = Config.expand(cpp_command(CONFIG[‘CPPOUTFILE’]))
    +else
  • cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)
    +end
    unless system “#{cpp} > confout” then
    exit 1
    end
···

Brian Candler B.Candler@pobox.com wrote:


Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- roberto@eurocontrol.fr
Usenet Canal Historique FreeBSD: The Power to Serve!

$ ruby -v -rmkmf -e ‘p Config::expand(cpp_command(“”))’
ruby 1.8.0 (2003-08-04) [i386-freebsd4.7]
“gcc -E -I/usr/local/lib/ruby/1.8/i386-freebsd4.7 -I/usr/local/lib/ruby/1.8/i386-freebsd4.7 -g -O2 conftest.c”

So now I have changed the following line in extconf.rb:

#cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)
cpp = Config::expand(cpp_command(“”))

And the next problem is that ‘make’ does nothing.

-bash-2.05b$ ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… yes
checking for mysql.h… yes
creating Makefile
-bash-2.05b$ gmake
gmake: Nothing to be done for `all’.

The relevant section of Makefile:


all: Makefile

clean:
@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)

So indeed, there is nothing to do. Hmm!

Regards,

Brian.

···

On Mon, Aug 04, 2003 at 10:59:05PM +0900, ts wrote:

cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)

Can you try ?

 Config::expand(cpp_command(""))

all: Makefile

Put

   create_makefile("mysql")

at the end, i.e. after creation of mysql.c

Guy Decoux

No joy yet:

$ ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… yes
checking for mysql.h… yes
creating Makefile
creating Makefile
/usr/local/lib/ruby/1.8/mkmf.rb:896:in create_makefile': undefined method close’ for nil:NilClass (NoMethodError)
from extconf.rb:63

Regards,

Brian.

···

On Mon, Aug 04, 2003 at 11:22:26PM +0900, ts wrote:

all: Makefile

Put

create_makefile(“mysql”)

at the end, i.e. after creation of mysql.c

creating Makefile
creating Makefile

Try to remove the first create_makefile("mysql")

Guy Decoux

That was it. Thank you!

For anyone else who needs it, here’s a summary of what I needed to do (note:
not tested under 1.6.8, so additional changes may be needed for mysql-ruby
to compile on both platforms)

Regards,

Brian.

— mysql-ruby-2.4.4.orig/extconf.rb Tue Jan 28 23:59:59 2003
+++ mysql-ruby-2.4.4/extconf.rb Mon Aug 4 16:00:26 2003
@@ -24,13 +24,12 @@
else
exit 1
end
-create_makefile(“mysql”)

make mysql constant

File::open(“conftest.c”, “w”) do |f|
f.puts src
end
-cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, ‘’)
+cpp = Config::expand(cpp_command(“”))
unless system “#{cpp} > confout” then
exit 1
end
@@ -58,3 +57,6 @@
end
end
end

···

On Mon, Aug 04, 2003 at 11:45:39PM +0900, ts wrote:

creating Makefile
creating Makefile

Try to remove the first create_makefile(“mysql”)

+create_makefile(“mysql”)
+