erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
887 stars 190 forks source link

Build instructions for Windows? #208

Closed bspeice closed 5 years ago

bspeice commented 6 years ago

I'm interested in using this for projects in Windows, and I see there's an Appveyor build going (and plenty of issues related to windows) but I have no idea how to actually install/use it. Can instructions be compiled on how to make use of this?

rotty commented 6 years ago

I don't have access to a Windows development environment, and have been relying on the community for making rust-zmq work with Windows. It is my impression that the bindings work on Windows, but there still might be rough edges. Perhaps you could attempt getting it to work and document steps needed for the benefit of other Windows developers?

My (naive) understanding is that you'd build and install zmq itself, and then run cargo build, pointing it to the zmq installation as noted in the README. The details can be gleamed from appveyor.bat.

Michael-F-Bryan commented 6 years ago

I ran into a similar issue in that the zmq crate doesn't compile out of the box on windows.

To get things working I had to:

As a side note, zmq-sys build script should probably either try to build zmq from source or panic!() with an error message if zmq isn't found on the local system. This is roughly what happens when building libgit2-sys.

zachlute commented 5 years ago

FWIW, I just put up PR #239 to do the build and link on Windows. You still have to install CMake yourself, but it should handle everything else. I don't know how active this project is at this point, but I'm open to input.

hansieodendaal commented 5 years ago

Hi @zachlute, I am having problems building rust-zmq on Windows.

  1. I cloned the latest libzmq 4.3.2 (have to use it) from the master branch, and built it with CMake in MS Visual Studio 2017 using the CMake -> Install -> ZeroMQ menu option, all tests passing successfully afterwards.

  2. I renamed libzmq-mt-s-4_3_2.lib to zmq.lib

  3. I cloned https://github.com/erickt/rust-zmq, and when running cargo build I get a link failure:

C:\Users\pluto\Documents\Code\zmq\rust-zmq>cargo build
   Compiling pkg-config v0.3.14
   Compiling error-chain v0.10.0
   Compiling toml v0.2.1
   Compiling libc v0.2.50
   Compiling cfg-if v0.1.7
   Compiling bitflags v0.7.0
   Compiling log v0.4.6
   Compiling metadeps v1.1.2
   Compiling zmq-sys v0.9.0 (C:\Users\pluto\Documents\Code\zmq\rust-zmq\zmq-sys)
   Compiling zmq v0.9.0 (C:\Users\pluto\Documents\Code\zmq\rust-zmq)
error: linking with `link.exe` failed: exit code: 1120
.
.
.
= note: build_script_build-86a0088bba3cd182.59e1lonbo0hbnwk3.rcgu.o : error LNK2019: unresolved external symbol __imp_zmq_has referenced in function _ZN18build_script_build4main17h3aa1d71f1a35e113E
          C:\Users\pluto\Documents\Code\zmq\rust-zmq\target\debug\build\zmq-86a0088bba3cd182\build_script_build-86a0088bba3cd182.exe : fatal error LNK1120: 1 unresolved externals

error: aborting due to previous error

error: Could not compile `zmq`.

What to do?

Thanks

hansieodendaal commented 5 years ago

Seems I have an answer for now. This is fixed in branch oblique:build-zmq.

To build rust-zmq execute cargo build --features static-libzmq

To add feature to own project add zmq = { git = "https://github.com/oblique/rust-zmq", branch = "build-zmq", features = ["static-libzmq"] } under [dependencies] section in the project's Cargo.toml.

See full answer in #241.

hansieodendaal commented 5 years ago

See PR #249 for dynamic linking of ZeroMQ. Also added basic installation instructions.

rotty commented 5 years ago

@bspeice There are now some instructions in the README regarding building on Windows, thanks to @hansieodendaal. If something is missing, please file a new issue, with specific information on what you tried and what did not work for you.

axil commented 4 years ago

https://github.com/oblique/rust-zmq no longer exists so cargo build --features static-libzmq doesn't work anymore. I'm having the same error as @hansieodendaal trying to build zmq on windows as a prerequisite for evcxr_jupyter. What is the right way to build it on Windows 10 nowadays? cargo build in the repo cloned from https://github.com/erickt/rust-zmq works fine though.

(I'm following all the instructions: installed zmq4.0.4 and renamed .lib and .dll files accordingly, added .dll dir to path)

hansieodendaal commented 4 years ago

I use dynamic linking of ZeroMQ as per PR #249, also used VS 2017 to compile it. Maybe you should post your error messages.

axil commented 4 years ago

@hansieodendaal Thank you for your reply. I've come up to the same solution: looks as if 4.0.4 version - the last compiled version I've found which comes with both .lib and .dll files - is too outdated for evcxr (as appears from the source code) and the current version (4.3.2) only comes with .dll file, but not .lib. So the only way out I see is to compile it manually.

hansieodendaal commented 4 years ago

Yes, that is what I did.

axil commented 4 years ago

Yes, I finally got it up and running. 4.3.2 version of libzmq compiled manually with cmake-gui and Visual Studio 2015 worked without any problems with evcxr_jupyter for me.

But alas, the speed of rust jupyter kernel makes it hardly usable as of today: calculates 2+2 for 1.7 sec.