Skip to content

Failed to build due to libproc #177

@AnabasisXu

Description

@AnabasisXu

Hi, I am trying to install shpool on Windows 10 but failed to build due to failure in compiling libproc:

   Compiling libproc v0.14.10
error[E0601]: `main` function not found in crate `build_script_build`
  --> C:\Users\Administrator\scoop\persist\rustup\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libproc-0.14.10\build.rs:23:13
   |
23 | fn main() {}
   |             ^ consider adding a `main` function to `C:\Users\Administrator\scoop\persist\rustup\.cargo\registry\src\index.crates.io-6f
17d22bba15001f\libproc-0.14.10\build.rs`

For more information about this error, try `rustc --explain E0601`.
error: could not compile `libproc` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
    Building [=====================>   ] 137/153: clap_builder, toml_edit

Turns out there is no target_os for windows:

#[cfg(target_os = "macos")]
fn main() {
    use std::env;
    use std::path::Path;

    let bindings = bindgen::builder()
        .header_contents("libproc_rs.h", "#include <libproc.h>")
        .layout_tests(false)
        .clang_args(&["-x", "c++", "-I", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"])
        .generate()
        .expect("Failed to build libproc bindings");

    let output_path = Path::new(&env::var("OUT_DIR")
        .expect("OUT_DIR env var was not defined"))
        .join("osx_libproc_bindings.rs");

    bindings
        .write_to_file(output_path)
        .expect("Failed to write libproc bindings");
}

#[cfg(any(target_os = "linux", target_os = "redox", target_os = "android"))]
fn main() {}

Sorry I am too new to Rust to know any solution.

Tried what is sugguested by rustc --explain E0601 in error log and modified the following code to the build.rs in the libproc-0.14.10 dir but it did not work:

#[cfg(any(target_os = "linux", target_os = "redox", target_os = "windows"))]
fn main() {
    // Your program will start here.
    println!("Hello world!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions