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 <string>

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

···

--
Darryl L. Pierce <mcpierce@gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant

in 1.8 you need to add

CONFIG['CC'] = 'g++'

before the header check

···

--
Posted via http://www.ruby-forum.com/.

and it got further than before.

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

···

--
Posted via http://www.ruby-forum.com/\.

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 */

···

On Wed, Apr 18, 2012 at 10:18 AM, Hans Mackowiak <lists@ruby-forum.com> wrote:

in 1.8 you need to add

CONFIG['CC'] = 'g++'

before the header check

--
Darryl L. Pierce <mcpierce@gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant

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:

···

On Wed, Apr 18, 2012 at 1:15 PM, Marc Heiler <lists@ruby-forum.com> wrote:

and it got further than before.

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

--
Darryl L. Pierce <mcpierce@gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant

I did this:

Config::CONFIG['CPP'] = "g++ -E"

and it got further than before.

···

On Wed, Apr 18, 2012 at 10:27 AM, Darryl L. Pierce <mcpierce@gmail.com> wrote:

On Wed, Apr 18, 2012 at 10:18 AM, Hans Mackowiak <lists@ruby-forum.com> 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:

--
Darryl L. Pierce <mcpierce@gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant