seattlerb / rubyinline

296 stars 41 forks source link

Just a quick question about using C libraries with rubyinline #36

Closed Thermatix closed 9 years ago

Thermatix commented 9 years ago

I was thinking of trying my hand at building a voxel engine using ruby. I want to build one because I've never done any 3D application building and voxels sound interesting to me. I want to do it in ruby because well, I like ruby and I understand it. Thing is ruby is kinda slow so obviously I'd do well to program bits of it in C, so I want to use rubyinline for it. My question is just, can I use c libraries (like graphic libraries for rendering) within any C inline code, if so how?

My second question is can we access ruby methods from within the C inline code? again, if so how?

I'm mostly just looking for directions to resources that could answer those questions and any others that might spring up.

pczarn commented 9 years ago
builder.include '<iostream>'
builder.include '<cairo-svg>'
builder.add_compile_flags '-lstdc++', '-lcairo' # for example. and so on
Thermatix commented 9 years ago

AH, I see, sweet, thanks a lot, I'll probably get started on the weekend, but thanks this makes things a lot easier.

zenspider commented 9 years ago

On Nov 20, 2014, at 09:12, Thermatix notifications@github.com wrote:

Thing is ruby is kinda slow so obviously I'd do well to program bits of it in C, so I want to use rubyinline for it.

My suggestion is to not jump straight to C. Do this in ruby. Measure. Find your bottlenecks. THEN address them in C. Piotr's flag advice is dead on.