thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
63 stars 4 forks source link

Couldn't find lib/libclang.so #14

Closed cipherchabon closed 3 years ago

cipherchabon commented 3 years ago

I am trying to run on linux the examples and I get this error:

thread 'main' panicked at 'Build failed: 
'dart run ffigen' failed to run successfully
stderr: 
stdout: Running in Directory: '/ffi_demos/rid/examples/dart/todo'
[SEVERE] : Couldn't find dynamic library in default locations.
[SEVERE] : Please supply one or more path/to/llvm in ffigen's config under the key 'llvm-path'.
[SEVERE] : Couldn't find lib/libclang.so in specified locations.
', rid_build.rs:32:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The llvm path is:

$ find /usr -iname "libclang.so" -print
/usr/lib/llvm-6.0/lib/libclang.so

I set the LINUX_LLVM_PATHS const en the rid-build/src/ffigen/host_props.rs file:

const LINUX_LLVM_PATHS: [&str; 6] = [
    "/usr/lib/llvm-6.0/lib/",
    "/usr/lib/llvm-9/lib/",
    "/usr/lib/llvm-10/lib/",
    "/usr/lib/llvm-11/lib/",
    "/usr/lib/",
    "/usr/lib64/",
];

I appreciate any help!!

MGlolenstine commented 3 years ago

FWIW, my libclang.so location is at /usr/lib/libclang.so and it works for me, so you could try linking to it and retrying.

cipherchabon commented 3 years ago

I finally solved it this way:

const LINUX_LLVM_PATHS: [&str; 1] = ["/usr/lib/llvm-6.0/lib/libclang.so"];
thlorenz commented 3 years ago

Reopened this since you shouldn't have to edit Rid to solve this. Sorry I didn't see the issue earlier. I'm surprised it didn't find your installation since "/usr/lib/llvm-6.0/lib/" is in the array of LLVM search paths, see below:

const LINUX_LLVM_PATHS: [&str; 6] = [
    "/usr/lib/llvm-6.0/lib/",
    "/usr/lib/llvm-9/lib/",
    "/usr/lib/llvm-10/lib/",
    "/usr/lib/llvm-11/lib/",
    "/usr/lib/",
    "/usr/lib64/",
];

These paths are passed to ffigen see configuration llvm-paths in which it looks for libclang.so among others. Maybe something isn't working correctly there?

Alternatively we could provide the path to the actual library file as in:

const LINUX_LLVM_PATHS: [&str; 6] = [
    "/usr/lib/llvm-5.0/lib/libclang.so",
    "/usr/lib/llvm-9/lib/libclang.so",
    "/usr/lib/llvm-10/lib/libclang.so",
    "/usr/lib/llvm-11/lib/libclang.so",
    "/usr/lib/libclang.so",
    "/usr/lib64/libclang.so",
];

Could you try if that works? If so we can PR with that change and fix it for everyone.

cipherchabon commented 3 years ago

I just tested it and it works.
Solved in https://github.com/thlorenz/rid/pull/18