HOWTO?: fix extconf.rb to use g++?

J

Jeremy Henty

Is there a supported way to get extconf.rb to use g++ instead of gcc?
I found the following references but none of them give a really
definitive answer.

http://www.angelfire.com/electronic2/issac/rb_cpp_ext_tut.txt
http://www.rubygarden.com/ruby?WritingExtensionInCpp
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/42146
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/83208

This came up when I tried to fix the build of ruby-fltk. It uses this
hack:

# Use "g++" instead of "gcc"
CONFIG.each{|key, val|
if( val =~ /gcc/ )
CONFIG[key] = CONFIG[key].gsub("gcc", "g++")
end
}
if( defined?(LINK) )
LINK.gsub!("gcc", "g++")
end
if( defined?(CPP) )
CPP.gsub!("gcc", "g++")
end

.... but it doesn't work in Ruby 1.8.2 ; the configuration tests still
run gcc , so some of them misfire, the build gets misconfigured and
breaks. My current fix is:

[ Config::CONFIG, Config::MAKEFILE_CONFIG, ].each{|config|
config.each{|key, val|
if( val =~ /gcc/ )
config[key] = config[key].gsub("gcc", "g++")
end
}
}
if( defined?(LINK) )
LINK.gsub!("gcc", "g++")
end
if( defined?(CPP) )
CPP.gsub!("gcc", "g++")
end

.... which seems to work but I've no idea if I've covered all the
bases. Any suggestions?

Cheers,

Jeremy Henty
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top