sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
804 stars 76 forks source link

compile error on macosx #14

Closed outersky closed 6 years ago

outersky commented 7 years ago

cargo run --example minimal just output error message:

warning: unused manifest key: badges.appveyor.repository
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
   Compiling sciter-rs v0.4.16 (file:///Volumes/src/git/rust/rust-sciter)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Volumes/src/git/rust/rust-sciter/target/debug/examples/minimal-049750bad57ec635.0.o" "-o" "/Volumes/src/git/rust/rust-sciter/target/debug/examples/minimal-049750bad57ec635" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Volumes/src/git/rust/rust-sciter/target/debug/deps" "-L" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libsciter-e229de1bcb7d347a.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/liblazy_static-4345d0db7d7e9b05.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc_foundation-cd7bec3c0f31e91a.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libblock-81bb5816adb186e4.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc_id-f01a1943dfb75bb9.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc-2834ac60b01b7699.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libmalloc_buf-826d6968858cdff6.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/liblibc-6451aa7d8103c93e.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-f1544d51c14ee547.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-0973ad751bdffbae.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-30637a1739b412eb.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-6ce8560490ee791c.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcollections-77c40ab2fac1172e.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-40208fb59386bff5.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-4b56f5c0b7251555.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-cba64299ce12485f.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-a98ebaa82aaee358.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-cfc94a4f91ad8df0.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-51cf9867f46a760f.rlib" "-l" "sciter-osx-64" "-framework" "Foundation" "-l" "System" "-l" "objc" "-l" "objc" "-l" "objc" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m"
  = note: ld: library not found for -lsciter-osx-64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error

error: Could not compile `sciter-rs`.

To learn more, run the command again with --verbose.
pravic commented 7 years ago

library not found for

Need to add sciter-osx-64 to your DYLD_LIBRARY_PATH: steps.

outersky commented 7 years ago

I've tried that before I opened this issue, but It did not work.

Now I resolved it with an extra build.rs:

fn main() {
    let path = "/soft/sciter-sdk/bin.osx";
    println!("cargo:rustc-link-search=native={}", path);
}

I'm using rust 1.15.1

artemkoff commented 7 years ago

I've got the same issue on Linux. Even though ldconfig -p | grep sciter gives the correct output. As @outersky pointed out, adding and extra build.rs helped.

pravic commented 7 years ago

The problem with build.rs - you need to know the full path to sdk. May be it's better to install sciter dylib in a common path which ld knows about.

WClouds commented 6 years ago

I've got the same issue on macos 10.12.6, and rustc is 1.19.0.

error: linking withccfailed: exit code: 1 | = note: "cc" "-m64" "-L" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/zhaiyafei/git/rust-sciter/target/debug/examples/minimal-ab102b078478d352.0.o" "-o" "/Users/zhaiyafei/git/rust-sciter/target/debug/examples/minimal-ab102b078478d352" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps" "-L" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libsciter-4f0d11e49be98da9.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/liblazy_static-4518bdaa60b81936.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libobjc_foundation-96c5644bef01938b.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libblock-0ffb223aeb965583.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libobjc_id-d63846a64e0fdd6d.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libobjc-6be275b7eff774e7.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/libmalloc_buf-c25e65c3bf4be6b3.rlib" "/Users/zhaiyafei/git/rust-sciter/target/debug/deps/liblibc-02127acf702dfb78.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-438eba4cd7d88a45.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-00160610bfa2c7b4.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-88eece318c5ccb15.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-646fe8114e6965a2.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcollections-7d6da376f6405c93.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-ab03bba0be78edaa.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-3d46a711e5badb84.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-31c7158cd96c571c.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-a732f07ce6fa7392.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-ee2a935baf6741f5.rlib" "/Users/zhaiyafei/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-53f5ee584666574a.rlib" "-l" "sciter-osx-64" "-framework" "Foundation" "-l" "System" "-l" "objc" "-l" "objc" "-l" "objc" "-l" "System" "-l" "resolv" "-l" "pthread" "-l" "c" "-l" "m" = note: ld: library not found for -lsciter-osx-64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

harvath commented 6 years ago

Having the same problem. Setting the DYLD_LIBRARY_PATH doesn't work. Even ln -s path/to/sciter-sdk/bin.osx/sciter-osx-64.dylib usr/local/lib doesn't work. Could this be a High Sierra issue?

pravic commented 6 years ago

LIBRARY_PATH with path to the bin.osx may be will help?

a7ul commented 6 years ago

Facing the same issue . Tried ln -s path/to/sciter-sdk/bin.osx/sciter-osx-64.dylib usr/local/lib Also tried creating a build.rs as mentioned by @outersky . None of it works. I am on High Sierra .. Using rust v1.25

Also tried setting DYLD_LIBRARY_PATH. No effect

pravic commented 6 years ago

@master-atul What about LIBRARY_PATH? It is needed during link time. DYLD - for run time.

a7ul commented 6 years ago

This is the error I am getting . And I have set the mentioned environment variables

rust-sciter git:(master) ✗ cargo clean
➜  rust-sciter git:(master) ✗ cargo run --example minimal
   Compiling block v0.1.6
   Compiling libc v0.2.40
   Compiling lazy_static v1.0.0
   Compiling sciter-rs v0.5.35 (file:///Users/atulr/Projects/Hobby/sciterapp/rust-sciter)
   Compiling malloc_buf v0.0.6
   Compiling objc v0.2.2
   Compiling objc_id v0.1.0
   Compiling objc-foundation v0.1.1
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.1y16o1qfye96o7m0.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.2kjrmm4fe2aha78f.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.2lyh15q6cjwzy18c.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.3rngp6bm2u2q5z0y.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.436dotimmrgzkwfa.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.45nf4z58qqykpcpi.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.45pc7c65foh9i35f.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.4jdnq7xfjeka1bt.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.4yh8x2b62dcih00t.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.4ypvbwho0bu5tnww.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.63mmpc50mjcb0lb.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.9elsx31vb4it187.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.kt25z0521ngsjub.rcgu.o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.ku9bptz0ino7xvu.rcgu.o" "-o" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/examples/minimal-5af5bdb354b43036.crate.allocator.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps" "-L" "/Users/atulr/Tools/scitersdk/bin.osx" "-L" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libsciter-4360e81d86a2bba7.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libobjc_foundation-ba5e8ef7865abe20.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libblock-7443a04081a39601.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libobjc_id-e4a84c0e3935a5d5.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/liblazy_static-960db699ba55062f.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libobjc-20bf12aebb434ed0.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/libmalloc_buf-0d246eb0d6b71c87.rlib" "/Users/atulr/Projects/Hobby/sciterapp/rust-sciter/target/debug/deps/liblibc-4843a624bceec38e.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-16d4d162f6c33ad8.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-c956526c78148c18.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-6b9fbbb00609f807.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-dab623c20d8d7baf.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-84c8031ea0d710a3.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-513802a765e0ff6c.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-61a8b8deed7aa9b0.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-6050b75f0dcb5748.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-5679663c8f16ff35.rlib" "/Users/atulr/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-d093db457f61f0c4.rlib" "-l" "sciter-osx-64" "-framework" "Foundation" "-l" "System" "-l" "objc" "-l" "objc" "-l" "objc" "-l" "System" "-l" "resolv" "-l" "pthread" "-l" "c" "-l" "m"
  = note: ld: library not found for -lsciter-osx-64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error

error: Could not compile `sciter-rs`.

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

➜  rust-sciter git:(master) ✗ echo $LIBRARY_PATH
/Users/atulr/Tools/scitersdk/bin.osx

➜  rust-sciter git:(master) ✗ echo $DYLD_LIBRARY_PATH
/Users/atulr/Tools/scitersdk/bin.osx

➜  rust-sciter git:(master) ✗ ls -l /Users/atulr/Tools/scitersdk

total 112
drwxr-xr-x@  8 atulr  staff    256 Mar 31 16:02 bin
drwxr-xr-x@  2 atulr  staff     64 Feb 19 19:47 bin.android
drwxr-xr-x@  4 atulr  staff    128 Mar 31 16:09 bin.gtk
drwxr-xr-x@  2 atulr  staff     64 Feb 19 19:47 bin.ios
drwxr-xr-x@ 12 atulr  staff    384 Mar 31 16:10 bin.osx
drwxr-xr-x@ 12 atulr  staff    384 Feb 19 19:47 demos
drwxr-xr-x@  5 atulr  staff    160 Feb 19 19:47 demos.GLFW
drwxr-xr-x@  2 atulr  staff     64 Feb 19 19:47 demos.android
drwxr-xr-x@  5 atulr  staff    160 Feb 19 19:47 demos.osx
drwxr-xr-x@  6 atulr  staff    192 Feb 19 19:47 demos.win
drwxr-xr-x@ 17 atulr  staff    544 Feb 19 19:47 doc
drwxr-xr-x@ 35 atulr  staff   1120 Mar 23 08:51 include
drwxr-xr-x@  2 atulr  staff     64 Feb 19 19:47 lib
-rwxr-xr-x@  1 atulr  staff   2701 Feb 19 19:47 license.htm
-rwxr-xr-x@  1 atulr  staff  47670 Mar 31 16:00 logfile.htm
drwxr-xr-x@ 16 atulr  staff    512 Feb 19 19:47 notes
-rwxr-xr-x@  1 atulr  staff    287 Feb 19 19:47 readme.txt
drwxr-xr-x@ 90 atulr  staff   2880 Feb 19 19:47 samples
drwxr-xr-x@ 15 atulr  staff    480 Apr  5 21:55 sqlite
drwxr-xr-x@  9 atulr  staff    288 Feb 19 19:47 widgets
➜  rust-sciter git:(master) ✗ 
a7ul commented 6 years ago
➜   rust-sciter git:(master) ✗ echo $LIBRARY_PATH
/Users/atulr/Tools/scitersdk/bin.osx

➜  rust-sciter git:(master) ✗ echo $DYLD_LIBRARY_PATH
/Users/atulr/Tools/scitersdk/bin.osx
pravic commented 6 years ago

Okay. Could you copy the sciter-osx-64.dylib as a libsciter-osx-64.dylib in bin.osx. Try to build. Will it help?

And note that the sciter-osx-64.dylib is required in run time anyway.

a7ul commented 6 years ago

That worked !! copy the sciter-osx-64.dylib as a libsciter-osx-64.dylib in bin.osx

Thanks @pravic

pravic commented 6 years ago

Well, then it seems that the current ld forbids sciter-osx-64.dylib resolution from a -lsciter-osx-64 option. It always was against the rules, but it worked until now.

An allowed form would be -l:sciter-osx-64.dylib , but I doubt that it is supported by Rust.

Another way is to rename the sciter-osx-64.dylib to the libsciter-osx-64.dylib, as it was done for Linux in 3.3.1.6. Or, even, to the libsciter-osx.dylib.

Anyway, I've added dynamic loading with --features shared (even with ability to specify the dylib path) that will be default eventually.

m-hilgendorf commented 6 years ago

This info should be added to the readme.md

pravic commented 6 years ago

Unfortunately, OSX version is the least tested due to hardware access absence.

m-hilgendorf commented 6 years ago

No worries, totally understandable. I'll submit a PR if I can find out how to avoid the workaround, if not I can submit an edit to the readme on it if that's fine?

pravic commented 6 years ago

Yes, it will be okay to improve the README.