rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.45k stars 52 forks source link

Cross compile from macos m1 to x86_64-unknown-linux-gnu - error: unable to find libraries. #141

Closed andrew-rj closed 1 year ago

andrew-rj commented 1 year ago

Hello! Thank you for building this tool. I've found it immensely useful in simplifying my workflow.

I am having some trouble cross-compiling an application for x86_64-unknown-linux-gnu or x86_64-unknown-linux-musl from a Mac m1. The application I'm trying to cross-compile has dependencies for libpcap and libhwloc when being compiled for linux. This is the error that I'm getting:

error: linking with `/Users/andrew/Library/Caches/cargo-zigbuild/0.16.10/zigcc-x86_64-unknown-linux-gnu.sh` failed: exit status: 1
...
  = note: ld.lld: error: unable to find library -lpcap
          ld.lld: error: unable to find library -lhwloc

I'm trying to build with this command:

cargo zigbuild --target x86_64-unknown-linux-gnu

I have hwloc and libpcap installed via homebrew on my Mac, but I think that this is looking for the linux libraries, and I don't think those are anywhere for zigbuild to use. Is there a way to resolve dependencies like this for zigbuild? I'm sorry if I am just oblivious to this.