andrewshadura / bsd-pidfile-rs

Rust wrapper for pidfile_* functions from libbsd/libutil
MIT License
2 stars 2 forks source link

Get `undefined reference` when attempting to cross compile for the Raspberry Pi (armhf) #2

Open D1plo1d opened 3 years ago

D1plo1d commented 3 years ago

pidfile-rs is working great for me on x64 but now trying to cross-compile it to armhf I get the following error:

  = note: /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /home/d1plo1d/git_repos/teg/target/armv7-unknown-linux-gnueabihf/debug/deps/libpidfile_rs-aa73a5ed2abdce1e.rlib(pidfile_rs-aa73a5ed2abdce1e.pidfile_rs.c101mk4m-cgu.0.rcgu.o): in function `pidfile_rs::Pidfile::new':
          /home/d1plo1d/.cargo/registry/src/github.com-1ecc6299db9ec823/pidfile-rs-0.1.0/src/lib.rs:124: undefined reference to `pidfile_open'
          /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /home/d1plo1d/git_repos/teg/target/armv7-unknown-linux-gnueabihf/debug/deps/libpidfile_rs-aa73a5ed2abdce1e.rlib(pidfile_rs-aa73a5ed2abdce1e.pidfile_rs.c101mk4m-cgu.0.rcgu.o): in function `pidfile_rs::Pidfile::write':
          /home/d1plo1d/.cargo/registry/src/github.com-1ecc6299db9ec823/pidfile-rs-0.1.0/src/lib.rs:156: undefined reference to `pidfile_write'
          /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /home/d1plo1d/git_repos/teg/target/armv7-unknown-linux-gnueabihf/debug/deps/libpidfile_rs-aa73a5ed2abdce1e.rlib(pidfile_rs-aa73a5ed2abdce1e.pidfile_rs.c101mk4m-cgu.0.rcgu.o): in function `<pidfile_rs::Pidfile as core::ops::drop::Drop>::drop':
          /home/d1plo1d/.cargo/registry/src/github.com-1ecc6299db9ec823/pidfile-rs-0.1.0/src/lib.rs:183: undefined reference to `pidfile_remove'
          collect2: error: ld returned 1 exit status

I've installed the armhf version of libbsd-dev via sudo apt-get install libbsd-dev:armhf. Is there any thing else I should need to do to get pidfile-rs to find pidfile_remove?

D1plo1d commented 3 years ago

So it looks like adding:

pkg_config::Config::new().probe("libbsd").unwrap()

shows this to be a pkg_config cross compilation issue.