Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install zmq4 Go Windows #180

Open
const97 opened this issue Jan 26, 2022 · 21 comments
Open

Install zmq4 Go Windows #180

const97 opened this issue Jan 26, 2022 · 21 comments

Comments

@const97
Copy link

const97 commented Jan 26, 2022

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?

@berkantay
Copy link

berkantay commented Oct 12, 2022

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

@berkantay
Copy link

@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

@ThakkarChandresh
Copy link

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

@berkantay
Copy link

berkantay commented Oct 19, 2023

@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?

@ThakkarChandresh
Copy link

@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\[email protected]\reactor.go:10:4: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:11:9: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:21:16: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:23:12: undefined: Poller
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:61:34: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:61:49: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:68:37: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\ctxoptions_windows.go:21:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\[email protected]\ctxoptions_windows.go:42:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\[email protected]\utils.go:17:12: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\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\[email protected]\reactor.go:10:4: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:11:9: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:21:16: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:23:12: undefined: Poller
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:61:34: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:61:49: undefined: State
..\..\go\pkg\mod\github.com\pebbe\[email protected]\reactor.go:68:37: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\ctxoptions_windows.go:21:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\[email protected]\ctxoptions_windows.go:42:12: undefined: Context
..\..\go\pkg\mod\github.com\pebbe\[email protected]\utils.go:17:12: undefined: Socket
..\..\go\pkg\mod\github.com\pebbe\[email protected]\utils.go:17:12: too many errors

Can you please help me i need it anyhow!!

@berkantay
Copy link

berkantay commented Oct 19, 2023

@ThakkarChandresh Could you send the environment variables you set?

@ThakkarChandresh
Copy link

ThakkarChandresh commented Oct 19, 2023

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

@berkantay
Copy link

@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.

@ThakkarChandresh
Copy link

@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

@berkantay
Copy link

  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.

@ThakkarChandresh
Copy link

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

@berkantay
Copy link

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

@ThakkarChandresh
Copy link

ThakkarChandresh commented Oct 19, 2023

image
Like this?

Still same error

@berkantay
Copy link

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

@ThakkarChandresh
Copy link

image
image

Yes they are correct

@berkantay
Copy link

How is the result?

@ThakkarChandresh
Copy link

ThakkarChandresh commented Oct 20, 2023

# 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

@berkantay
Copy link

berkantay commented Oct 20, 2023

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

@ThakkarChandresh
Copy link

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?

@Cparker96
Copy link

@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

@c-afanasyev
Copy link

c-afanasyev commented Oct 12, 2024

This is how i managed to do this: https://stackoverflow.com/a/70910659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants