Questions tagged [ruby-native-extensions]

13 questions
3
votes
2 answers

Ruby gem native extension with Crystal?

I'm just trying to gather some general information, as I'm looking to improve performance of ActiveModelSerializers. I've also never written a native extension before, but have looked at some C extensions and Rust extensions. My Questions: Has…
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
2
votes
0 answers

Ruby native extensions: target and file names

I've written a few Ruby native extensions, the usual deal is to have a "target name", foo say, then have a file ext/foo/foo.c which defines Init_foo. I have a need (see below) to have a different filename, ext/foo/bar.c say, which defines Init_foo…
jjg
  • 907
  • 8
  • 18
2
votes
0 answers

Ruby Native Extension - use other C extension gem

I am writing ruby c extension which has a dependency on another C extension. currently, I am calling the other C extension via rb_funcall I would like to call the C extension's function directly (include its header and call the public function) Is…
Yosi
  • 2,936
  • 7
  • 39
  • 64
2
votes
1 answer

Ruby Native Extension - Manual Compilation

I created new Ruby C Extension and hosted it in GitHub, and I install via Bundler (gem 'my_cool_gem', git: '..'). But when I run the application (rails s) I get an error - cannot load such file -- my_cool_gem/my_cool_gem My current solution, is to…
Yosi
  • 2,936
  • 7
  • 39
  • 64
2
votes
3 answers

ruby native extension: undefined symbol

I'm attempting to create a ruby native extension, but when I run rake which uses ext/example_project/extconf.rb to build my project and run my tests under test/, I get the following error when the tests are…
JesseBuesking
  • 6,496
  • 4
  • 44
  • 89
1
vote
1 answer

Why could GCC prefer to use stdio.h file from later in the include path?

While compiling a Ruby gem's native extension, I get this error according to logs: LD_LIBRARY_PATH=.:/home/linuxbrew/.linuxbrew/Cellar/ruby@3.1/3.1.3_1/lib "gcc-12 -M -o conftest…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
1
vote
0 answers

Specify C and C++ compiler paths when building Ruby gem

gem allows specifying build arguments, however I can't find a build argument to override the CC and CXX constants in the Makefile generated by mkmf (the defaults appear to come from RbConfig::CONFIG). How can I specify which compiler to use when…
squirl
  • 1,636
  • 1
  • 16
  • 30
1
vote
1 answer

How do you pass a block, written in C, to Ruby's rb_mod_refine?

Perhaps more generally, how do you pass a block, written in C, to another C function that accepts a block? I know I can do something like this: VALUE refine_foobar(VALUE block_arg, VALUE data, int argc, VALUE* argv) { // block code here return…
Cameron
  • 641
  • 1
  • 7
  • 18
1
vote
0 answers

Errors when using pre-compiled gems with native extensions on Plesk-managed machines without development options

I am aiming to have a production machine running a Ruby on Rails app. However, this production machine is managed with Plesk and allows only very rudimentary access, but was promised to be able to run Ruby on Rails apps. Indeed it is in principle…
0
votes
1 answer

Install Ruby gem with Native Extension

I am creating a new gem that uses FFI to create a ruby binding to webview C library The gem structure is as follows: . ├── ... ├── Rakefile ├── ext │   └── webview │   ├── extconf.rb │   ├── webview.cc │   └── webview.h ├── lib │   ├──…
Mohamed Anwer
  • 172
  • 2
  • 15
0
votes
0 answers

Error when trying to install colored http gem

I'm trying to install the gem colored http but I got this error when I run "gem install colored http" : ERROR: Failed to build gem native extension. current directory:…
0
votes
0 answers

ruby native wrap c library segfault

I'm attempting to wrap a small library I've written in c, and I think I'm on the home stretch to getting it working. The library has some pretty solid tests around it, and I've ran it through valgrind to remove any memory leaks and glaring issues.…
JesseBuesking
  • 6,496
  • 4
  • 44
  • 89
0
votes
1 answer

issues building ruby native extension

I've created some code in c that I'd like to call from ruby. I've used this article as a guide, but I'm having problems getting it to run without linking issues. To start, I have to directly copy the source files into my ext/NAME/ directory. They…
JesseBuesking
  • 6,496
  • 4
  • 44
  • 89