I am learning how to write Ruby C extensions and I'm past the simplest examples. I was trying to achieve something with sockets so I attempted to create an extension which would define a class under rb_cIPSocket.

At the top of my C file I have:

#include "rubysocket.h"

And I am receiving:

...s.c:3:31: error: rubysocket.h: No such file or directory

Which is most probably the case. However, I tried all possible paths:

#include "rubysocket.h"
#include "socket/rubysocket.h"
#include "ext/socket/rubysocket.h"
#include <rubysocket.h>
#include <socket/rubysocket.h>
#include <ext/socket/rubysocket.h>

And this is my extconf.rb:

require 'mkmf'
dir_config("my_ext")
have_library("c", "main")
create_makefile("my_ext")

And so on. What am I actually missing here? Why can't I include that header file? I am using OSX with RVM and Ruby 1.9.3-p448. Thank you.

有帮助吗?

解决方案

where does rubysocket.h live? If it's in the heart of ruby's source code then odds are it is "private" for ruby's use, but you can look it up like...

VALUE ipSocketClass = rb_const_get("IPSocket");

or the like. GL!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top