mkmf extconf include path

C

Christophe Mckeon

hi,

how do you set the include file path for your extension? can it be done
using mkmf? right now i'm going #include "../drp.h" which is kind of
ugly.

thanks,
_c
 
D

Daniel Berger

hi,

how do you set the include file path for your extension? can it be done
using mkmf? right now i'm going #include "../drp.h" which is kind of
ugly.

find_header('drp.h', '..')

Regards,

Dan
 
C

Christophe Mckeon

Daniel said:
find_header('drp.h', '..')

Regards,

Dan

thanks but that doesn't work, i still get errors

Building native extensions. This could take a while...
drp_ext_rule_engine.c:20:17: error: drp.h: No such file or directory

this is what my extconf looks like:

require 'mkmf'

have_library 'c', 'main'
find_header 'drp.h', '..'
create_makefile 'drp_ext_rule_engine'

and in my C file i have:

#include "drp.h"

but if i have:

#include "../drp.h"

either with or without the find_header it works fine. i am
building through the extensions attribute of gemspec, not by hand.

regards,
_c
 
A

ara.t.howard

thanks but that doesn't work, i still get errors

Building native extensions. This could take a while...
drp_ext_rule_engine.c:20:17: error: drp.h: No such file or directory

this is what my extconf looks like:

require 'mkmf'

have_library 'c', 'main'
find_header 'drp.h', '..'
create_makefile 'drp_ext_rule_engine'

and in my C file i have:

#include "drp.h"

but if i have:

#include "../drp.h"

either with or without the find_header it works fine. i am
building through the extensions attribute of gemspec, not by hand.

you mean you are creating an extonf.rb?

-a
 
D

Daniel Berger

thanks but that doesn't work, i still get errors

Works for me. I put a 'bar.h' in the toplevel directory. My extconf.rb
file looks like this:

require 'mkmf'
find_header('bar.h', '..')
create_makefile('foo')

The foo.c file looks like this:

#include <ruby.h>
#include <bar.h> /* Quotes or braces will work */

void Init_foo(){
VALUE mFoo = rb_define_class("Foo", rb_cObject);
}

$ ruby extconf.rb
checking for #include <bar.h>
... yes
creating Makefile

$ make
gcc -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.9.1 -I/usr/local/lib/
ruby/1.8/i686-darwin8.9.1 -I. -I.. -fno-common -g -O2 -pipe -fno-
common -c foo.c
cc -dynamic -bundle -undefined suppress -flat_namespace -L"/usr/local/
lib" -o foo.bundle foo.o -ldl -lobjc

After you run extconf.rb, open up the Makefile and look for INCFLAGS.
You should see "-I..". If you don't then something went seriously
wrong.

Regards,

Dan
 
A

ara.t.howard

cc -dynamic -bundle -undefined suppress -flat_namespace -L"/usr/local/
lib" -o foo.bundle foo.o -ldl -lobjc

so even you are on a mac now eh dan? ;-)

-a
 
D

Daniel Berger

so even you are on a mac now eh dan? ;-)

Yah. This is why you'll be seeing a bunch of new releases from the
sysutils project in the coming weeks. :)

I'll probably setup bootcamp and do the Vista/OS X thing at some
point.

Dan
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top