Questions tagged [ruby-c-extension]

Loadable modules written in C which provide additional functionality for the Ruby language.

C extensions are shared objects that can be loaded by the MRI at runtime. They are typically created in order to allow Ruby to interface with low-level code, but can also used to improve the speed of expensive computations.

Many modules in the Ruby standard library are implemented as C extensions in order to optimize for speed or reuse existing libraries.

176 questions
0
votes
1 answer

How to add Ruby C Extension into Rails application?

I have Rails 4 application. I created simple C extension with Ruby C API This extension convert file from data folder and returns output based on that file(some_file.f) |-- data | |--some_file.f |-- ext | `-- my_ext | |-- extconf.rb | …
tomekfranek
  • 6,852
  • 8
  • 45
  • 80
0
votes
1 answer

Unable to complete simple example for Rice (Ruby). What am I missing?

I am following the tutorial for ruby Rice at http://rice.rubyforge.org/index.html. My end goal is to be able to wrap a c++ object that I already have running, but call it from Ruby. In following the tutorial I can create a C++ class fine and call…
Noremac
  • 3,445
  • 5
  • 34
  • 62
0
votes
1 answer

Is it possible to use rb_cIPSocket in ruby C extension

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…
user56250
0
votes
1 answer

Recommended way to build ruby c-extension for testing

I was building a rubygem by using gem build $gemname.gemspec && gem install $gemname-0.0.1.gem However, this doesn't seem to be the best way to test the gem, since it moves it out of the local environment and into the rubygems paths. Is the…
aciniglio
  • 1,777
  • 1
  • 16
  • 18
0
votes
1 answer

Ruby C extension can't be 'require'd

I have a ruby extension that I'm building as a gem. It has this directory structure |-ext \-cowboy \- extconf.rb |- cowboy.c |-lib \- cowboy.rb |- cowboy \- version.rb |- test \- test_cowboy.rb When I build it and install it,…
aciniglio
  • 1,777
  • 1
  • 16
  • 18
0
votes
1 answer

Ruby C extension compile error: expected ‘)’ before ‘event’

I am trying to extend Ruby with a C extension in order to add an event hook. Unfortunately, I get the following error: timber.c:7: error: expected ‘)’ before ‘event’ timber.c: In function ‘timber_init_event_hook’: timber.c:15: error: ‘timber_trap’…
Paul Engel
  • 73
  • 1
  • 7
0
votes
1 answer

How does one overwrite a rb_ function in a ruby c extension?

I am having trouble figuring out how to override a rb_ function (like rb_ivar_get) in c. I have the following code: #include "ruby.h" void Init_metaobject(); VALUE meta_cObject = Qnil; VALUE meta_ivar_get(VALUE obj, VALUE mId, VALUE mWarn); VALUE…
tydeu
  • 649
  • 5
  • 11
0
votes
1 answer

Will Ruby extensions built in OS X work on Linux?

I want to make a Ruby extension for a C (with C++ libraries) program that will run on a CentOS server, but it would be more convenient for me to work on a Mac (especially without having to reinstall all the 3rd party libraries). Since they're both…
rm -rf slash
  • 296
  • 3
  • 12
-1
votes
2 answers

Can you instantialise `Data` class's data inside Ruby?

When trying to use an instance method of a Ruby-C-Class: RubyCClass.new.someMethod() Ruby is raising the following error: Error: wrong argument type RubyCClass (expected Data) Is there any way I can instantiate the class properly such that…
Sancarn
  • 2,575
  • 20
  • 45
-1
votes
1 answer

pg_ext.so: undefined symbol: rb_thread_select

bash-4.2# rake db:create /opt/rubystack-2.3.1-0/ruby/bin/.ruby.bin: symbol lookup error: /opt/rubystack-2.3.1-0/ruby/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.so: undefined symbol: rb_thread_select bash-4.2# ruby -v ruby 2.3.1p112 (2016-04-26…
Albert.Qing
  • 4,220
  • 4
  • 37
  • 49
-1
votes
1 answer

Scripting language to compiled language or pure compiled language, which is faster?

Recently I have coded a application in jruby and made .jar file from it and deployed same in tomcat. I have also read an article on jruby which says "Jruby- scalablity of java and easiness of ruby". Here I want to know does coding like this in…
Paritosh Singh
  • 6,288
  • 5
  • 37
  • 56
1 2 3
11
12