From: Ryan Davis Date: 2011-06-25T05:22:12+09:00 Subject: Re: Explicitly setting compiler to C++ in extconf.rb... On Jun 24, 2011, at 11:50 , Antonio Terceiro wrote: > Michael Edgar escreveu isso aí: >> On Jun 23, 2011, at 7:30 PM, Antonio Terceiro wrote: >> >>> require 'rbconfig' >>> RbConfig::CONFIG['CPP'] = RbConfig::CONFIG['CPP'].gsub('gcc', 'g++') >>> require 'mkmf' >>> have_header('string') or raise('You need ') >>> create_makefile('test') >> >> Don't do this. The following is sufficient: >> >> require 'mkmf' >> have_library('stdc++') >> create_makefile('laser/BasicBlock') >> >> That's a working extconf.rb for a gem I'm actively working on. Adding stdc++ >> makes mkmf use g++ on my system. > > Actualy mkmf uses g++ for C++ code (.cc,.cpp), and not because you > checked for 'stdc++' > > The original problem is not checking for a C++ standard header, is > checking for a header that is actually a C++ header that happens to > #include a C++ standard header. Doing that with `gcc -E` instead of `g++ > -E` will just not work. > > Of course, mkmf could provide a way to say "please check for everything > using C++ instead of C". mkmf provides: with_cflags(flags) # :yields: so you should be able to do something like with_cflags("-x c++") do # ... end