Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while running Ruby code from C #5

Closed
madgen opened this issue Oct 31, 2015 · 3 comments
Closed

Problem while running Ruby code from C #5

madgen opened this issue Oct 31, 2015 · 3 comments

Comments

@madgen
Copy link

madgen commented Oct 31, 2015

After a clean compilation I get the following error when I try to run the compiled binary on OS X El Capitan.

dyld: lazy symbol binding failed: Symbol not found: _ruby_init
  Referenced from: /Users/user/p/c/playground/./a.out
  Expected in: flat namespace

dyld: Symbol not found: _ruby_init
  Referenced from: /Users/user/p/c/playground/./a.out
  Expected in: flat namespace

[1]    64228 trace trap  ./a.out

The compilation flags are as follows:

$ gcc call_ruby.c $(pkg-config --cflags --libs ruby-2.2)

And pkg-config evaluates to the following:

-I/Users/user/.rbenv/versions/2.2.2/include/ruby-2.2.0/x86_64-darwin15 -I/Users/user/.rbenv/versions/2.2.2/include/ruby-2.2.0 -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -lpthread -lgmp -ldl -lobjc

I tried to recompile Ruby as I upgraded OS version in the meantime, but didn't change anything.

@dmitry
Copy link

dmitry commented Aug 10, 2016

@madgen post a ruby and C code here :)

@silverhammermba
Copy link
Owner

Sorry for being insanely late seeing this. I don't have an OSX machine so I can't reproduce. But at a glance I don't see any -lruby for linking with the Ruby lib. That seems consistent with the missing symbol. I'm not sure why pkg-config doesn't pick that up.

@silverhammermba
Copy link
Owner

silverhammermba commented Jan 22, 2018

Years later and now I have an OSX machine. I still can't reproduce this sort of error. Check out the Makefiles from _test and _include in the repo: they work fine on OSX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants