Ubuntu
找不到 Libudev.pc
我正在建構一個 Rust 項目,每當我嘗試建構時,我都會得到
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"libudev\"` did not exi t successfully: exit status: 1\nerror: could not find system library 'libudev' required by the 'libudev-sys' crate\n\n--- stderr\nPackage l ibudev was not found in the pkg-config search path.\nPerhaps you should add the directory containing `libudev.pc'\nto the PKG_CONFIG_PATH e nvironment variable\nNo package 'libudev' found\n"', /home/nikola/.cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.r s:38:41
它的錯誤消息很清楚,但問題是,我可以在網上找到的所有內容,10 多個解決方案都提到了安裝
pkg-config
和libudev-dev
. 我已經安裝並重新安裝了,但我沒有libudev.pc
文件執行
apt search udev
給出這些條目librust-libudev-sys-dev/focal 0.1.4-1 amd64 FFI bindings to libudev - Rust source code libu2f-udev/focal,focal,now 1.1.10-1 all [installed] Universal 2nd Factor (U2F) common files libudev-dev/focal-updates,now 245.4-4ubuntu3.17 amd64 [installed] libudev development files libudev1/focal-updates,now 245.4-4ubuntu3.17 amd64 [installed,automatic] libudev shared library
缺少
libudev.pc
➜ ~project git:(master) ✗ locate libudev.pc ➜ ~project git:(master) ✗
➜ ~pkgconfig: echo $PKG_CONFIG_PATH ➜ ~pkgconfig:
嘗試這個:
echo 'export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig/"' >> $HOME/.bashrc
**編輯:**忘記提及您必須關閉並重新打開任何打開的終端或
source $HOME/.bashrc
在目前終端中執行才能使更改生效。
您使用
pkg-config
的是 Homebrew,預設情況下只知道 Homebrew-packages 庫。在Ubuntu上,如果您打算
libudev-dev
使用Ubuntu 提供的軟體包(例如.pkg-config``pkg-config``apt