pebbe / zmq4

A Go interface to ZeroMQ version 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install zmq4 Go Windows

const97 opened this issue · comments

I would like to use zmq4 (https://github.com/pebbe/zmq4) in Go Programming Language on a Windows system. This need to have ZeroMQ (libzmq) installed (https://zeromq.org/download/ or https://github.com/zeromq/libzmq). Unfortunately, I can not find a way to install libzmq on Windows. Can anyone help me?

Hi Const, I do also try to build for windows too. Did you have any progress about that? @const97

@const97 I am able to compile and use it on windows. The steps are

  1. Install vcpkg vcpkg
  2. Then run vcpkg.exe install zeromq

Then you will have the output below
image

  1. Set the go environment variables as show in the README.md
  2. Copy the libzmq-mt-4_3_4.dll file under your source code.
  3. Run go build main.go

@berkantay it's not working!! Your problem is solved or not?

@ThakkarChandresh It has been a year since I solved the issue. Therefore solution from a year ago MAY NOT be working today. Could you give more details about your issue so that maybe I can help?

@berkantay Thanks for replying

First, when I imported the "github.com/pebbe/zmq4" library i was facing the issue

# github.com/pebbe/zmq4
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:10:4: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:11:9: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:21:16: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:23:12: undefined: Poller
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:61:34: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:61:49: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:68:37: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\ctxoptions_windows.go:21:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\ctxoptions_windows.go:42:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\utils.go:17:12: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\utils.go:17:12: too many errors

Then I've changed the CGO_ENABLED env to 1
go env -w CGO_ENABLED=1

Then I'm facing the issue

# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

As it says there is no gcc, so I've installed the Mingw64 bit gcc compiler, then it gave the error

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

Then i tried your way,
Install vcpkg vcpkg
Then run vcpkg.exe install zeromq

(Note: I've uninstalled mingw64 bit gcc as it's not working)

Then set the env variables according to the readme file, again it was giving the same error
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

So I've reset the CGO_ENABLED env to 0
go env -w CGO_ENABLED=0

And now again I'm getting the error

# github.com/pebbe/zmq4
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:10:4: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:11:9: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:21:16: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:23:12: undefined: Poller
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:61:34: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:61:49: undefined: State
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\reactor.go:68:37: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\ctxoptions_windows.go:21:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\ctxoptions_windows.go:42:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\utils.go:17:12: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\zmq4@v1.2.10\utils.go:17:12: too many errors

Can you please help me i need it anyhow!!

@ThakkarChandresh Could you send the environment variables you set?

image

@berkantay My Current environment variables

And also set the PATH in System Variables to point the libzmq-mt-4_3_5.dll file

C:\dev\vcpkg\packages\zeromq_x64-windows\bin

@ThakkarChandresh There are several issues here;

  1. You do not have to point .dll file to the path. .dll is needed at the same point with your executable.
  2. CGO_CFLAGS='-ID:/dev/vcpkg/installed/x64-windows/include'and CGO_LDFLAGS='-LD:/dev/vcpkg/installed/x64-windows/lib -l:libzmq-mt-4_3_4.lib' must also be in the PATH.
  3. I couldn't see mingw64-gcc on path.
  4. You do not have to add libzmq to the path.

@berkantay

  1. You do not have to point .dll file to the path. .dll is needed at the same point with your executable.
    -> removed And added with the executable.
    image

  2. CGO_CFLAGS='-ID:/dev/vcpkg/installed/x64-windows/include'and CGO_LDFLAGS='-LD:/dev/vcpkg/installed/x64-windows/lib -l:libzmq-mt-4_3_4.lib' (must also be in the PATH. can you please explain? under system variables ? and how?)
    image

  3. I couldn't see mingw64-gcc on path.
    ->Downloaded from this link
    image

now with CGO_ENABLED=1

facing the same error

# runtime/cgo
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
  1. First step is OK.
  2. Second step is half correct. Please pass the correct path to CGO_FLAGS and CGO_LDFLAGS. These are required for CGO to link libraries. /dev/vcpkg is not valid for Windows.
  3. You have to set the binary path of install mingw-gcc to PATH manually.

Now is it okay?
image

What does this -ID: and -LD: means as this path /dev/vcpkg is available in my C:/

image

You have to set the binary path of install mingw-gcc to PATH manually.
Already there

CGO_CFLAGS and CGO_LDFLAGS should be in environment variable PATH as the same place with mingw/bin.

image
Like this?

Still same error

If those are the correct paths as it mentioned above then yes.

image
image

Yes they are correct

How is the result?

# runtime/cgo
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

I've two questions

  1. why this is saying 64-bit mode
  2. What does this -ID: and -LD: means

Your gcc version may be 32 bit
ID and LD is related with linking libzmq to zmq4. https://stackoverflow.com/a/39867163/13524252

How to check that gcc is 32 bit or 64 bit, and if it's the case then any reference or guide to install 64 bit gcc?

@berkantay Do you have a solution for this error? I installed Visual Studio Community edition, rebooted it, then ran the install command again for zeromq and this is what I received:

Screenshot 2023-12-20 125325