d-unsed / ruru

Native Ruby extensions written in Rust
MIT License
834 stars 40 forks source link

Linking error #1

Closed chills42 closed 8 years ago

chills42 commented 8 years ago

I thought I'd try this out, but immediately ran into a linking error:

⇒  cargo build
   Compiling ruru v0.5.0
   Compiling libc v0.1.12
/Users/craig.hills/.cargo/registry/src/github.com-88ac128001ac3a9a/libc-0.1.12/rust/src/liblibc/lib.rs:81:21: 81:39 warning: lint raw_pointer_derive has been removed: using derive with raw pointers is ok
/Users/craig.hills/.cargo/registry/src/github.com-88ac128001ac3a9a/libc-0.1.12/rust/src/liblibc/lib.rs:81 #![allow(bad_style, raw_pointer_derive)]
                                                                                                                              ^~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/registry/src/github.com-88ac128001ac3a9a/ruru-0.5.0/src/types.rs:16:1: 16:85 warning: trait bounds are not (yet) enforced in type definitions [E0122]
/Users/craig.hills/.cargo/registry/src/github.com-88ac128001ac3a9a/ruru-0.5.0/src/types.rs:16 pub type Callback<I: Object, O: Object> = extern fn(Argc, *const AnyObject, I) -> O;
                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/craig.hills/.cargo/registry/src/github.com-88ac128001ac3a9a/ruru-0.5.0/src/types.rs:16:1: 16:85 help: run `rustc --explain E0122` to see a detailed explanation
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/Users/craig.hills/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/craig.hills/code/bruw/target/debug/deps/ruru-89284decc76f4754.0.o" "-o" "/Users/craig.hills/code/bruw/target/debug/deps/libruru-89284decc76f4754.dylib" "/Users/craig.hills/code/bruw/target/debug/deps/ruru-89284decc76f4754.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/craig.hills/code/bruw/target/debug/deps" "-L" "/Users/craig.hills/code/bruw/target/debug/deps" "-L" "/usr/local/opt/rbenv/versions/2.3.0/lib" "-L" "/Users/craig.hills/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-l" "ruby" "-Wl,-force_load,/var/folders/0j/s2tz5nh135325kr5czrkq_0m274bbw/T/rustc.sQqN26Zd1r6K/liblibc-dd3420cb049117bb.rlib" "-L" "/Users/craig.hills/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-l" "std-4fda350b" "-l" "c" "-l" "m" "-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::h19b8a2c489e1971cRia in ruru-89284decc76f4754.0.o
  "_rb_sym2id", referenced from:
      binding::symbol::sym_to_id::hfeed45964b43a6ffRha in ruru-89284decc76f4754.0.o
  "_rb_id2sym", referenced from:
      binding::symbol::id_to_sym::h4480ba545371b02cnha in ruru-89284decc76f4754.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 `ruru`.
⇒  rbenv version
2.3.0 (set by /usr/local/opt/rbenv/version)
⇒  rustc -V
rustc 1.8.0 (db2939409 2016-04-11)
⇒  cc --version
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
d-unsed commented 8 years ago

Hi @chills42!

It turned out that one additional step was missing in the Readme. For now the crate cannot be used as static library, but MRI is built without any dynamic libraries by default (rbenv/ruby-build#35)

Please run

CONFIGURE_OPTS=--enable-shared rbenv install 2.3.0

to build ruby along with dylibs and rebuild the crate.

I've updated Readme. Thanks for creating the issue!

chills42 commented 8 years ago

Thanks! Built fine this time!