I'm trying to setup a Ruby gem that bundles the Swig-generated bindings
for Qpid, along with native Ruby code on top of those bindings. In
extconf.rb I have directives to verify that the header files and
libraries are present. For example:
abort "Missing address header" unless have_header "qpid/messaging/Address.h"
This line always fails, even though the header file is present. It
fails with this message:
have_header: checking for qpid/messaging/Address.h... -------------------- no
"gcc -E -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I.
-I/home/mcpierce/Programming/Qpid/qpid/cpp/include/ -DRICE -fPIC -fno-inline conftest.c -o conftest.i"
In file included from /home/mcpierce/Programming/Qpid/qpid/cpp/include/qpid/messaging/exceptions.h:26:0,
from /home/mcpierce/Programming/Qpid/qpid/cpp/include/qpid/messaging/Address.h:26,
from conftest.c:1:
/home/mcpierce/Programming/Qpid/qpid/cpp/include/qpid/types/Exception.h:25:18:
fatal error: string: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include <qpid/messaging/Address.h>
/* end */
Specifically, it's failing since, at line 25 of Exception.h, is:
#include <string>
which is a Standard C++ header. But the Makefile generated is always
using gcc (rather than g++) to check. If I dump the checks for the
headers then everything works, but that's not the Right Way(tm) to me to
do this.
Any help on how to tell Ruby to use g++?
···
--
Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"
Darryl L. Pierce escreveu isso aí:
Specifically, it's failing since, at line 25 of Exception.h, is:
#include <string>
which is a Standard C++ header. But the Makefile generated is always
using gcc (rather than g++) to check. If I dump the checks for the
headers then everything works, but that's not the Right Way(tm) to me to
do this.
Any help on how to tell Ruby to use g++?
You can try something like this:
require 'rbconfig'
RbConfig::CONFIG['CPP'] = RbConfig::CONFIG['CPP'].gsub('gcc', 'g++')
require 'mkmf'
have_header('string') or raise('You need <string>')
create_makefile('test')
···
--
Antonio Terceiro <terceiro@softwarelivre.org>
http://softwarelivre.org/terceiro
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.
Michael Edgar
adgar@carboni.ca
http://carboni.ca/
···
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 <string>')
create_makefile('test')
Hrm, no joy. It's still failing with the same error in mkmf.log.
···
On 06/23/2011 07:39 PM, Michael Edgar wrote:
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<string>')
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.
--
Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"
Michael Edgar escreveu isso aí:
> require 'rbconfig'
> RbConfig::CONFIG['CPP'] = RbConfig::CONFIG['CPP'].gsub('gcc', 'g++')
> require 'mkmf'
> have_header('string') or raise('You need <string>')
> 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".
···
On Jun 23, 2011, at 7:30 PM, Antonio Terceiro wrote:
--
Antonio Terceiro <terceiro@softwarelivre.org>
http://softwarelivre.org/terceiro
Just checked, and you're right - same thing happens to me if I insert
a "have_header" for one of my header files. It's failing because mkmf
is creating a file called "conftest.c" and not "conftest.cc" - changing the
name of the file makes it work. Ugh.
It looks like a bug in mkmf.rb:407, in "cpp_command," it uses CONFTEST_C
which ends in .c .
Michael Edgar
adgar@carboni.ca
http://carboni.ca/
···
On Jun 23, 2011, at 10:07 PM, Darryl L. Pierce wrote:
On 06/23/2011 07:39 PM, Michael Edgar wrote:
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.
Hrm, no joy. It's still failing with the same error in mkmf.log.
mkmf provides:
with_cflags(flags) # :yields:
so you should be able to do something like
with_cflags("-x c++") do
# ...
end
···
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 <string>')
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".
Ugh. So, for now, I'll have to ignore checking for the headers and just
file a bug against mkmf to support C++ header checks.
···
On Fri, Jun 24, 2011 at 11:22:22AM +0900, Michael Edgar wrote:
On Jun 23, 2011, at 10:07 PM, Darryl L. Pierce wrote:
> On 06/23/2011 07:39 PM, Michael Edgar wrote:
>>
>> 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.
>
> Hrm, no joy. It's still failing with the same error in mkmf.log.
Just checked, and you're right - same thing happens to me if I insert
a "have_header" for one of my header files. It's failing because mkmf
is creating a file called "conftest.c" and not "conftest.cc" - changing the
name of the file makes it work. Ugh.
It looks like a bug in mkmf.rb:407, in "cpp_command," it uses CONFTEST_C
which ends in .c .
--
Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"
I see you already reported this issue [1]. Thanks. 
[1] Feature #4924: mkmf have_header fails with C++ headers - Ruby master - Ruby Issue Tracking System
···
On Fri, Jun 24, 2011 at 11:22:22AM +0900, Michael Edgar wrote:
On Jun 23, 2011, at 10:07 PM, Darryl L. Pierce wrote:
> On 06/23/2011 07:39 PM, Michael Edgar wrote:
>>
>> 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.
>
> Hrm, no joy. It's still failing with the same error in mkmf.log.
Just checked, and you're right - same thing happens to me if I insert
a "have_header" for one of my header files. It's failing because mkmf
is creating a file called "conftest.c" and not "conftest.cc" - changing the
name of the file makes it work. Ugh.
It looks like a bug in mkmf.rb:407, in "cpp_command," it uses CONFTEST_C
which ends in .c .
--
Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"
That did the trick! I added "-x c++" to my $CFLAGS and the system looked
for the headers correctly.
Thank you.
···
On Sat, Jun 25, 2011 at 05:22:12AM +0900, Ryan Davis wrote:
mkmf provides:
with_cflags(flags) # :yields:
so you should be able to do something like
with_cflags("-x c++") do
# ...
end
--
Darryl L. Pierce <mcpierce@gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"