C extension guide #10

Closed
wants to merge 17 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

jdleesmiller commented Aug 26, 2011

I've filled out the C extension guide. It follows on from the 'make your own gem' guide.

The conventions are drawn from this tutorial
http://tenderlovemaking.com/2009/12/18/writing-ruby-c-extensions-part-1/
http://tenderlovemaking.com/2010/12/11/writing-ruby-c-extensions-part-2/
which I've used to create a couple of C extensions that seem to work well.

Comments very welcome!

Member

luislavena commented Aug 26, 2011

Great! thank you!

Something that is word mentioning and will be great to have in the guide is the mention to rake-compiler: http://github.com/luislavena/rake-compiler which provides simplification of your rake tasks and works across platforms (OSX uses .bundle instead of .so for example)

It also provides the option to distribute pre-compiled gems for your platform or cross compilation.

If this becomes the official guides, then good recommendations will be worth to include (and is not shameless plug, several projects are using it for the same reason and DRY).

Contributor

jdleesmiller commented Aug 26, 2011

OK; good point. I've added a link to rake-compiler in the Rakefile section.

I haven't used it myself (but I aim to try it soon!), so feel free to suggest different words.

Member

luislavena commented Aug 26, 2011

Great, thank you!

@qrush and @sandal, can you guys proof read this? I'm not a native english speaker so everything sounds good to me :)

Thank you!

Contributor

practicingruby commented Aug 26, 2011

@luislavena, I can check the copy, sure. I'll try to look into this over the weekend. Did the technical content look okay to you? If so, I'll try to get this merged soon.

Member

luislavena commented Aug 26, 2011

@sandal, tech aspects looks good.

Contributor

cldwalker commented Aug 26, 2011

@sandal I've already started proofing this, technically as well. Should be done soon
@jdleesmiller Thanks for the guide!

Contributor

practicingruby commented Aug 26, 2011

@cldwalker: Okay, if you get finished before I get around to it, then please go ahead and merge. If I don't see this request updated by tomorrow sometime I'll begin on it myself, but no sense duplicating efforts if we can avoid it :)

cldwalker closed this in 289b441 Aug 26, 2011

Contributor

jdleesmiller commented Aug 26, 2011

@cldwalker: great -- thanks for turning this around so quickly!

I have two minor quibbles for consideration:

(1) I can see why you moved the last paragraph from the extconf.rb section to a new "About Make" section, but now the next section refers to hola/hola.so without having explained where it comes from. Could we add the following, shorter, paragraph to the end of the extconf.rb section, and delete the About Make section?

The output from make is a dynamically linked library (DLL), which can be required into ruby. On Linux, the output file is hola/hola.so, because we passed hola/hola to create_makefile, and .so is the file extension for a DLL on Linux.

(2) The last paragraph of the Extension Naming section now uses <$g> with angle brackets (was <gem_name> before), but the previous paragraph just uses $g. It would be better to use the same for both (I prefer $g).

Anyway, lookin' good -- thanks again!

Member

luislavena commented Aug 26, 2011

@cldwalker: actually compiled C-extensions will be .so on Windows and either .bundle or .dylib on OSX. Talk about the extension itself seems a moot point, specially since Ruby works on other platforms beyond OSX/Linux/Windows

Saying that RbConfig::CONFIG['DLEXT´] will report the file extension used for your platform seems better :-)

@marocchino marocchino added a commit to marocchino/guides that referenced this pull request Mar 27, 2015

@marocchino marocchino Merge pull request #10 from marocchino/ko-patterns
Translate patterns
81ea126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment