tox-rs / rstox

Rust bindings to c-toxcore
GNU General Public License v3.0
16 stars 7 forks source link

Unable to use this on Mac OSX #19

Closed Chuongv closed 8 years ago

Chuongv commented 8 years ago

I create a new cargo project cargo new project --bin Then I add the line to my Cargo.toml [dependencies.rstox] git = "https://github.com/suhr/rstox.git"

I also confirmed that libtoxcore and libtoxav are in my /user/local/lib

Get the following error when trying to build

error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "/Users/cvu/Github/demo/RustChat/target/debug/RustChat.0.o" "-o" "/Users/cvu/Github/demo/RustChat/target/debug/RustChat" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/cvu/Github/demo/RustChat/target/debug" "-L" "/Users/cvu/Github/demo/RustChat/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin" "-L" "/Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin" "/Users/cvu/Github/demo/RustChat/target/debug/deps/librstox-ab1806e399b3d68b.rlib" "/Users/cvu/Github/demo/RustChat/target/debug/deps/liblibc-f654c8036439f8ef.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-71b07a99.rlib" "-l" "toxcore" "-l" "toxav" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin'
ld: library not found for -ltoxcore
clang: error: linker command failed with exit code 1 (use -v to see invocation)
suhr commented 8 years ago

Hm. Does it compile with LDFLAGS=-L/user/local/lib?

Chuongv commented 8 years ago

I should of mention that I am using cargo build. Is there a way for me to add a linker flag to it?

I added the /user/local/lib to this, not sure if it's the same thing? But same issue.

cvu at cvu-macpro in ~/Github/demo/RustChat
$ cc -m64 -L /usr/local/lib /usr/local/lib/rustlib/x86_64-apple-darwin/lib /Users/cvu/Github/demo/RustChat/target/debug/RustChat.0.o -o /Users/cvu/Github/demo/RustChat/target/debug/RustChat -Wl,-dead_strip -nodefaultlibs /Users/cvu/Github/demo/RustChat/target/debug/deps/librstox-ab1806e399b3d68b.rlib /Users/cvu/Github/demo/RustChat/target/debug/deps/liblibc-f654c8036439f8ef.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-a5fc0d6c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-a5fc0d6c.rlib -L /Users/cvu/Github/demo/RustChat/target/debug -L /Users/cvu/Github/demo/RustChat/target/debug/deps -L /usr/local/lib/rustlib/x86_64-apple-darwin/lib -L /Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin -L /Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin -l toxcore -l toxav -l System -l pthread -l c -l m -l compiler-rt
ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin'
ld: can't map file, errno=22 file '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
suhr commented 8 years ago

Well, weird. But the issue doesn't seem to depend on rstox. Does it compile anything else?

Chuongv commented 8 years ago

I have been going through the rust tutorial and doing the sample programs and they have been compiling fine. But yea, it doesn't seem to depend on rstox. I can't find anywhere in the rstox project where this issue might be. Anyways, feel free to close this one.

Chuongv commented 8 years ago

Closing this one, I don't think this is rstox related. Thanks for the help though! :smile:

Chuongv commented 8 years ago

@suhr

Hm. Does it compile with LDFLAGS=-L/user/local/lib?

Ooops I didn't add that linker flag correctly. It compiles now. I wonder why cargo doesn't add that originally?

Chuongv commented 8 years ago

Okay figured it out, LIBRARY_PATH was not set. Since cargo/rust looks at that to figure out where the libs are located. I thought it would look at pkg-config to figure out where that is.