Extconf.rb and checking for C++ headers

I’m extending our project [1] with some native extensions. Our code is
written (currently) all in C++, and we use Swig to provide Ruby
bindings.

For the extconf.rb file previous I’ve just had:

—8<[snip]—
require ‘mkmf’

create_makefile(‘nonblockio’)
—8<[snip]—

However, now I’d like to customize the file a little more in order to
support both Ruby 1.8 and 1.9. Between those two versions of Ruby we
have a different set of header files that are required. So, anyway,
I’ve added the following the check for headers:

—8<[snip]—
require_header(“qpid/messaging/exceptions.h”)
require_header(“qpid/messaging/Address.h”)
require_header(“qpid/messaging/Connection.h”)
—8<[snip]—

The problem comes with the first header. It’s being found, but because
it contains C++ includes, specified:

#include

mkmf is failing saying it “can’t find” the header, though the error is:

/usr/local/include/qpid/types/Exception.h:25:18: fatal error: string:
No such file or directory

How do I tell mkmf to use C++ headers?

[1] http://qpid.apache.org

in 1.8 you need to add

CONFIG[‘CC’] = ‘g++’

before the header check

On Wed, Apr 18, 2012 at 10:27 AM, Darryl L. Pierce [email protected]
wrote:

On Wed, Apr 18, 2012 at 10:18 AM, Hans M. [email protected] wrote:

in 1.8 you need to add

CONFIG[‘CC’] = ‘g++’

before the header check

Tried it but no joy. In the mkmf.log I’m not seeing where it’s using
g++ instead:

I did this:

Config::CONFIG[‘CPP’] = “g++ -E”

and it got further than before.

On Wed, Apr 18, 2012 at 10:18 AM, Hans M. [email protected]
wrote:

in 1.8 you need to add

CONFIG[‘CC’] = ‘g++’

before the header check

Tried it but no joy. In the mkmf.log I’m not seeing where it’s using
g++ instead:

have_header: checking for qpid/messaging/exceptions.h…
-------------------- no

“gcc -E -I. -I/usr/lib64/ruby/1.8/x86_64-linux
-I…/…/…/…/ext/nonblockio -DRUBY18 -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
–param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing
-fPIC conftest.c -o conftest.i”
In file included from
/usr/local/include/qpid/messaging/exceptions.h:26:0,
from conftest.c:1:
/usr/local/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/exceptions.h>
/
end */

and it got further than before.

Still sounds as if you have an error? :slight_smile:

On Wed, Apr 18, 2012 at 1:15 PM, Marc H. [email protected]
wrote:

and it got further than before.

Still sounds as if you have an error? :slight_smile:

There was an error, but it turns out that additional error was my own
fault; i.e., I had created a copy of conftest.c to play with some
commandline arguments and then forgot to delete it from the extension
directory. I’m now good to go. :slight_smile: