problem about ruby-c-extension-Collection of common programming errors


  • aembke
    c++ ruby opencv ubuntu ruby-c-extension
    I’m trying to correctly link OpenCV shared libraries to a ruby c++ extension and for some reason any call to have_library() is failing for the opencv libraries. I installed opencv to /usr/local so the header files are all in /usr/local/include and the libraries are all in /usr/local/lib. I’ll attach my extconf.rb and related output below.require “mkmf-rice”dir_config(“opencv_core”, “/usr/local/include”, “/usr/local/lib”) unless have_library(“opencv_core”)raise “Could not find opencv_core” enddir

  • Matheus Moreira
    ruby rubygems ruby-c-extension extconf.rb
    I’m writing a gem, that includes a C extension. Usually when I write a gem, I follow a process of TDD, where I’ll write a failing spec and then work on the code until it passes, etc etc…With my C extension in “ext/mygem/mygem.c” and a valid extconf.rb configured in the gemspec’s “extensions”, how do I run my specs and still have my C extension loaded? When I make changes to the C code, what steps do I need to take to recompile the code?This is probably a stupid question, but typing ‘bundle i

  • Neil Slater
    ruby ruby-c-extension coercion
    I make use of Integer( param ) in Ruby and NUM2INT( param ) in native extensions as a way of accepting any param that could be cast to an Integer in my public interfaces.Recently I came across a difference in behaviour between Ruby 1.8 and 1.9 where 1.9 raises an error, but 1.8 makes an unwanted coercion from Symbol to Fixnum (or to an equivalent int in C):In 1.9.3, behaviour I want:1.9.3-p327 :001 > Integer( :foo ) TypeError: can’t convert Symbol into IntegerIn 1.8.7, behaviour I don’t want:

  • mukh007
    jruby ruby-c-extension
    Trying to install ruby-oci8 with jruby gemset. It’s giving me below error I’ve tried to use export JRUBY_OPTS=”–1.9 -Xcext.enabled=true” as suggested in other similar questions with no luck.$ jruby -S gem install ruby-oci8 Fetching: ruby-oci8-2.1.7.gem (100%) Building native extensions. This could take a while… ERROR: Error installing ruby-oci8: ERROR: Failed to build gem native extension./home/user/.rvm/rubies/jruby-1.7.5/bin/jruby extconf.rb /home/user/.rvm/rubies/jruby-1.7.5/lib/ruby/sha

  • Neil Slater
    ruby gem ruby-c-extension
    I am developing a gem, which is currently pure Ruby, but I have also been developing a faster C variant for one of the features. The feature is usable, but sometimes slow, in pure Ruby. The slowness would only impact some of the potential users (depends which features they need, and how they use them), so it makes sense to have the gem available with graceful fallback to Ruby-only functions if it cannot compile on a target system.I would like to maintain the Ruby and C variants of the feature in

  • slm
    ruby-on-rails ruby ruby-c-extension
    I’ve recently updated to Mountain Lion and re-installed Ruby, but when I try to run a test Rails app, I get an error message that says that “Rails is not currently installed” on my system. I do what it says, type sudo gem install rails and get:cleared faster_require caches due to new gem install… Successfully installed rails-3.2.7 1 gem installed Installing ri documentation for rails-3.2.7… Installing RDoc documentation for rails-3.2.7…But when I check to see which rails version is install

  • Josh Petitt
    c ruby ruby-c-extension
    I’ve written a simple Ruby C extension. A method expects the second parameter to be a string-ish VALUE.VALUE method_foo(VALUE self, VALUE key) {puts(RSTRING(key)->ptr);return key; }Its very easy to cause a segmentation fault by passing an integer rather than a string. How should I detect this and either prevent or recover in the C method?

  • Matheus Moreira
    ruby ruby-c-extension
    I am following instructions to http://people.apache.org/~rooneg/talks/ruby-extensions/ruby-extensions.html (page 6) and my make command is only returning make: Nothing to be done for ‘all’.Does anyone have any ideas?I am using ruby 1.9.2 and I’m on OSX 10.6.8SHELL = /bin/sh#### Start of system configuration section. ####srcdir = . topdir = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 hdrdir = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 arch_hdrdir = /Users/pcoder

  • Matheus Moreira
    c ruby debugging ruby-c-extension
    I’m building a simple C extension for a Ruby module, and I’m running into trouble with a segfault when I call another C function inside my extension. The basic flow of execution goes like this:I create a Ruby class and call an instance method on it, which Calls a C method in my extension, which Calls another C function, in a separate file but which compiled OKIt’s the last jump that seems to break. I’ve been able to reproduce the issue with almost no functionality but the function calls. I have

  • Matheus Moreira
    c ruby linker ruby-c-extension
    I keep getting this fairly obscure link error whenever I try to link my Ruby extension:/usr/bin/ld: Mg.o: relocation R_X86_64_PC32 against undefined symbol `init_window_class_under’ can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad valueI couldn’t find anything on this. I experimented for a while and it linked fine when I removed the header files, so I moved on without them (Yes, very bad idea).Turns out I need them, now. So, what is this error

  • sawa
    c++ ruby ruby-1.9.3 ruby-c-extension
    I am trying to compile a c++ extension for Ruby, and the compilation does not return an error, but it does not seem to be compiling correctly. What am I doing wrong?I have the main cpp script foo.cpp:#include <iostream> #include <ruby.h> extern “C”VALUE cFoo; void Init_foo(){cFoo = rb_define_class(“Foo”, rb_cObject);}and extconf.rb:require “mkmf” $libs += ” -lstdc++ ” create_makefile(“foo”)and within the directory of these files, I did$ ruby extconf.rb creating Makefile $ make compil

  • sawa
    c++ ruby g++ warnings ruby-c-extension
    I am trying to write a c++ extension for Ruby. In addition to the main file, I have a file extconf.rb:require “mkmf” $libs += ” -lstdc++ ” create_makefile(“file_name”)and, after doing ruby extconf.rb, when I try to compile it with g++ by typing make, I get the warning:cc1plus: warning: command line option “-Wdeclaration-after-statement” is valid for C/ObjC but not for C++I read that it is not harmful, but is there a way to avoid this warning? There is a person with the same problem here, but the

Web site is in building

I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money