Skip to content

linker cannot find -linput on NixOS #82

@ada4a

Description

@ada4a

I realize this sounds similar to #59, but I think the problem is slightly different: on NixOS, the reason the library can't be found is that it isn't present by default at all.

In many other C wrapper crates, the error about the missing library (like libudev and libxkbcommon) is emitted by pkg-config, which is at least somewhat more legible -- would it be possible to do something similar here as well?

Thanks in advance:)

EDIT: as I've since forgotten what the problem was myself, here's some more context:

When libudev is missing, I get the following error -- already on cargo build:

Wall of text

error: failed to run custom build command for `libudev-sys v0.1.4`

Caused by:
  process didn't exit successfully: `[REDACTED]/input.rs/target/debug/build/libudev-sys-e81444cfe6440a16/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
  /* omitted: a bunch more `cargo:rerun-if-env-changed`s */
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr

  thread 'main' (949047) panicked at ~/.cache/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libudev-sys-0.1.4/build.rs:38:41:
  called `Result::unwrap()` on an `Err` value: "pkg-config exited with status code 1\n> PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags libudev\n\npkg-config output:\n  Package libudev was not found in the pkg-config search path.\n  Perhaps you should add the directory containing `libudev.pc'\n  to the PKG_CONFIG_PATH environment variable\n  No package 'libudev' found\n\nThe system library `libudev` required by crate `libudev-sys` was not found.\nThe file `libudev.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.\nThe PKG_CONFIG_PATH environment variable is not set.\n\nHINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `libudev.pc`.\n"

But when libinput is missing, I get this error -- and only during cargo run (for which I used the example from the README, by copying it to src/main.rs)

A smaller, but somewhat more confusing, wall of text

error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "[REDACTED]/input.rs/target/debug/deps/rustcMzCIhW/symbols.o" "<53 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "[REDACTED]/input.rs/target/debug/deps/{libinput-9f3733a9dad8af94,liblog-d7ffaa050103d639,libbitflags-4cb5efb0e892aac1,libudev-659e820e2061d333,liblibudev_sys-7edc5c8b918313b4,libio_lifetimes-a156ffd2669da5d2,liblibc-337fe196a7e39b09,libinput_sys-43f63f96c531a42e}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-ludev" "-linput" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/[REDACTED]/input.rs/target/debug/deps/rustcMzCIhW/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/nix/store/i3p4h70l0qq32lizw0i4px8afn1y7g8w-systemd-minimal-libs-260.1/lib" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "[REDACTED]/input.rs/target/debug/deps/input-225b07b7190d606a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: unable to find library -linput
          collect2: error: ld returned 1 exit status

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