cberner / fuser

Filesystem in Userspace (FUSE) for Rust
MIT License
834 stars 114 forks source link

error when running example in m1 #205

Closed Annazhan closed 2 years ago

Annazhan commented 2 years ago

I try to run the hello.rs in example, but got this issue ld: library not found for -losxfuse. But I have already download the macFUSE . Then I follow the error instruction and download osxfuse, and I got another issue shown below, so I am wondering is it because my architecture of my computer or my settings? Thank you so much!

Screen Shot 2022-05-17 at 11 04 26
cberner commented 2 years ago

What version of macFUSE do you have? Unfortunately, I don't have a Mac to test with, but I think other people have successful used it with version 4. See this line: https://github.com/cberner/fuser/blob/5fb2992506aacd830a33fba157c0792f5cc25130/build.rs#L11

Annazhan commented 2 years ago

Right! I use 4.2.5 macFuse. And I solve that problem with changing searching fuse package sequence in pkg_config in build.rs. When using macOS, it will work when the pkg first search for osxfuse and then search for macfuse 4.0. I am not sure the reason of this, but currently it can work. The change is shown below:

#[cfg(target_os = "macos")]
        {
            if pkg_config::Config::new()
                .atleast_version("2.6.0")
                .probe("osxfuse") // for macFUSE 4.x
                .map_err(|e| eprintln!("{}", e))
                .is_ok()
            {
                println!("cargo:rustc-cfg=feature=\"libfuse2\"");
            } else {
                pkg_config::Config::new()
                    .atleast_version("2.6.0")
                    .probe("fuse") // for osxfuse 3.x
                    .map_err(|e| eprintln!("{}", e))
                    .unwrap();
                println!("cargo:rustc-cfg=feature=\"libfuse2\"");
            }
        }

Thank you for your reply!!