I am trying to create a C extension for ruby. I am very new to
development and have only just became familiar with ruby, so it im
really lost. I have looked at "How to create a C Extension in Ruby in
under five minutes" and it makes sense. The problem is that I dont know
what program(s) to use to compile the C code and the ruby code. I have
been using text documents for my ruby programming, so I have never
needed to compile them. So here are my questions. If I want to make a C
extension (following the model previously mentioned) what IDE do I use,
and what file format do I compile to? Also, where do I place the ruby
file and the C compiled file? And finally, will a simple notepad editor
work for this ruby development. Remember, I am new to programming in
general, so these questions may appear naive. Thanks.
What does your C extension do? It sounds a bit like you are jumping in the deep end with jeans and a woolly jumper on =]
Sam
···
On 08/14/2012 08:12 AM, Andy P. wrote:
I am trying to create a C extension for ruby. I am very new to
development and have only just became familiar with ruby, so it im
really lost. I have looked at "How to create a C Extension in Ruby in
under five minutes" and it makes sense. The problem is that I dont know
what program(s) to use to compile the C code and the ruby code. I have
been using text documents for my ruby programming, so I have never
needed to compile them. So here are my questions. If I want to make a C
extension (following the model previously mentioned) what IDE do I use,
and what file format do I compile to? Also, where do I place the ruby
file and the C compiled file? And finally, will a simple notepad editor
work for this ruby development. Remember, I am new to programming in
general, so these questions may appear naive. Thanks.
Well eventually it will communicate with a piece of hardware programmed
in C and retrieve data. For now, it should return 10. Here is the link
to the tutorial that I am basing this off of.
I am trying to create a C extension for ruby. I am very new to
development and have only just became familiar with ruby, so it im
really lost. I have looked at "How to create a C Extension in Ruby in
under five minutes" and it makes sense. The problem is that I dont know
what program(s) to use to compile the C code and the ruby code.
Make sure you have the ruby development libraries (e.g. in Ubuntu you
need ruby-dev and build-essential). That's another thing - this all
varies very much depending on which platform you're trying to use, and
you haven't even given this most basic piece of information.
If you are new to C as well, this is probably not the best place to
start.
You could try the RubyInline gem for embedding small snippets of C
directly in your Ruby, which might be useful depending on what it is
you're actually trying to achieve.
So the extension is running. If I type require 'C:\~~~~~\mytest' in IRB
then include MyTest and then type puts test1 it returns 10 (like it is
supposed to). The end goal is to have this working in SketchUp, and it
seems to glitch when I try to call the .so file outside of IRB.
This is the call in the IRB interface (the names have changed but they
are still representative of the same thing)
Sorry for the sporadic posting. I have figured out the plugin. The
extension works in SketchUp now. I had to download a older version of
ruby and change some lines of the config.h file. Then i had to compile
the makefile through nmake, not make in the VS 2010 command prompt.
Thanks.
Or, perhaps you have since you mention H/W comms. Would it be easier for the communication to happen from Ruby? (Since you don't define the means of the communication.)
-Rob
···
On Aug 13, 2012, at 4:38 PM, Andy P. wrote:
Well eventually it will communicate with a piece of hardware programmed
in C and retrieve data. For now, it should return 10. Here is the link
to the tutorial that I am basing this off of.