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

Linking error (with libruby present) #11

Closed
wezm opened this issue May 3, 2016 · 5 comments
Closed

Linking error (with libruby present) #11

wezm opened this issue May 3, 2016 · 5 comments

Comments

@wezm
Copy link

wezm commented May 3, 2016

I am experiencing the same issue as #1 but I have already built ruby with --enable-shared:

$ rbenv version
2.3.0 (set by /Users/wmoore/Projects/translation_middleware/.ruby-version)

$ ls ~/.rbenv/versions/2.3.0/lib
libruby.2.3.0-static.a libruby.2.3.dylib      pkgconfig
libruby.2.3.0.dylib    libruby.dylib          ruby

Error:

error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/Users/wmoore/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/wmoore/Projects/translation_middleware/target/debug/translation_middleware.0.o" "-o" "/Users/wmoore/Projects/translation_middleware/target/debug/libtranslation_middleware.dylib" "/Users/wmoore/Projects/translation_middleware/target/debug/translation_middleware.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/wmoore/Projects/translation_middleware/target/debug" "-L" "/Users/wmoore/Projects/translation_middleware/target/debug/deps" "-L" "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib" "-L" "/Users/wmoore/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/libruru-c125d47a5dbdbad9.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/libruby_sys-9c98563f5869bd84.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/liblibc-12d5d911cf5411c3.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/libstd-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/libcollections-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/librustc_unicode-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/librand-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/liballoc-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/liballoc_system-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/liblibc-4fda350b.rlib" "-Wl,-force_load,/var/folders/tg/d0k9t6855130nzcfjv7rcq0c0000gn/T/rustc.ch7vhH2EOR7i/libcore-4fda350b.rlib" "-l" "ruby" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib" "-l" "compiler-rt"
note: Undefined symbols for architecture x86_64:
  "_rb_funcallv", referenced from:
      binding::util::call_method::hd3cb17cf82fa681azia in libruru-c125d47a5dbdbad9.rlib(ruru-c125d47a5dbdbad9.0.o)
  "_rb_sym2id", referenced from:
      binding::symbol::sym_to_id::ha5d004a08aad5d8byha in libruru-c125d47a5dbdbad9.rlib(ruru-c125d47a5dbdbad9.0.o)
  "_rb_id2sym", referenced from:
      binding::symbol::id_to_sym::h7a1479f68e6b60724ga in libruru-c125d47a5dbdbad9.rlib(ruru-c125d47a5dbdbad9.0.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `translation_middleware`.

To learn more, run the command again with --verbose.

Using rustc 1.8.0 (db2939409 2016-04-11)

I note that in all the -L arguments to the compiler it includes "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib", which is no doubt the issue — I want to it to find the current rbenv ruby. Do you have any suggestions on how to get it to pick up the right ruby?

@d-unsed
Copy link
Owner

d-unsed commented May 3, 2016

Hi @wezm!

Can you please run $ rbenv global?

If it is something different than 2.3.0, try to temporarily set the global version to 2.3.0 and rebuild the crate.

$ rbenv global 2.3.0

It looks similar to this problem, I am looking for a solution.

@wezm
Copy link
Author

wezm commented May 3, 2016

Yep that's the issue. When I set the global version to 2.3.0 it compiles fine. (I normally have my global version set to system)

@wezm
Copy link
Author

wezm commented May 4, 2016

I did some more looking into this. The issue seems to stem from rbenv not finding the .ruby-version file when the build script invokes ruby. I was able to work around this without the need to change my global ruby by specifying the ruby version in the environment instead:

RBENV_VERSION=2.3.0 cargo build

@d-unsed
Copy link
Owner

d-unsed commented May 4, 2016

Wow that's really good news!

Thank you for looking into this!

@NullVoxPopuli
Copy link

I'm having this issue with chruby. it doesn't have a global setting. :-\

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