erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
886 stars 189 forks source link

Cannot cross-compile to x86_64-pc-windows-gnu #372

Open TabulateJarl8 opened 1 year ago

TabulateJarl8 commented 1 year ago

Hey! I am trying to cross-compile a program using zmq to x86_64-pc-windows-gnu on Arch Linux. I get errors that it can't find libraries such as sys/socket.h, netdb.h, sys/socket.h, sys/epoll.h, and SOCKET. I had installed the mingw version of libzmq, and I tried to point to it with the arguments PKG_CONFIG_PATH=/mingw64/lib/pkgconfig/ PKG_CONFIG_ALLOW_CROSS=1, but that didn't fix anything. How do I solve this problem?

TabulateJarl8 commented 1 year ago

Since this repository seems to be lacking activity, I switched to nanomsg with these Rust bindings

AgentRev commented 6 months ago

It appears that the zeromq-src library relied upon by zmq-sys is not that well adapted for cross-compilation. I had the same errors when compiling on Windows using MinGW, and it required applying some fixes to this file; under the target.contains("windows") section, I commented out the wepoll stuff and build.define("ZMQ_HAVE_IPC", "1"); then added build.define("ZMQ_HAVE_WINDOWS", "1");. This allowed me to successfully compile via MinGW with MSYS2.

I'm not exactly sure why zmq doesn't try to dynamically link libzmq first before attempting to compile ZeroMQ from source. It seems that was the case up to v0.9, but no longer in v0.10.