在安装Golang ZMQ(ZeroMQ)时遇到问题 – 致命错误:czmq.h:没有该文件或目录

huangapple go评论82阅读模式
英文:

Problem in Installing Golang ZMQ for windows - fatal error: czmq.h: No such file or directory

问题

我尝试在Golang中使用ZMQ库,并使用以下页面的指南:https://zeromq.org/languages/go/。根据文档,libsodiumlibzmqczmq是依赖项。

从https://jmeubank.github.io/tdm-gcc/download/下载GCC,并将其安装在C:\gcc目录中。

然后,为了安装vcpkg(用于安装其他软件包),下载并提取https://github.com/Microsoft/vcpkg存储库到C:\dev目录。使用以下命令进行安装:

C:\dev>bootstrap-vcpkg.bat

根据https://libsodium.gitbook.io/doc/installation安装libsodium,执行以下命令:

cd C:\dev
vcpkg integrate install
vcpkg install libsodium

使用以下命令安装libzmqczmq

vcpkg install zeromq:x64-windows-static
vcpkg install czmq:x64-windows-static

安装完依赖项后,我尝试安装Golang的zeromq。但运行以下命令时:

go get gopkg.in/zeromq/goczmq.v4

出现了以下错误:

go get gopkg.in/zeromq/goczmq.v4
# gopkg.in/zeromq/goczmq.v4
C:\Users\Noori\go\pkg\mod\gopkg.in\zeromq\goczmq.v4@v4.1.0\auth.go:4:10: fatal error: czmq.h: No such file or directory
    4 | #include "czmq.h"
      |          ^~~~~~~~
compilation terminated.

Windows和Golang版本:Windows 10-x64和Go 1.17.3

go version
go version go1.17.3 windows/amd64

我是一个Golang的初学者,请在这个领域帮助我。

英文:

I tried to use ZMQ library in Golang and use instructions from the following page: https://zeromq.org/languages/go/. Based on the document, libsodium, libzmq and czmq are dependencies.

GCC downloaded from https://jmeubank.github.io/tdm-gcc/download/ and installed in C:\gcc.

Then for installing vcpkg (used for installing other packages) the https://github.com/Microsoft/vcpkg repository is downloaded and extracted at C:\dev directory. The following command is used for installation:

C:\dev>bootstrap-vcpkg.bat

To install libsodium based on https://libsodium.gitbook.io/doc/installation, the following commands executed:

cd C:\dev
vcpkg integrate install
vcpkg install libsodium

To install libzmq and czmq following commands are used:

vcpkg install zeromq:x64-windows-static
vcpkg install czmq:x64-windows-static

After installing dependencies I tried to install zeromq for Golang. But running the following command:

go get gopkg.in/zeromq/goczmq.v4

Caused this error:

go get gopkg.in/zeromq/goczmq.v4
# gopkg.in/zeromq/goczmq.v4
C:\Users\Noori\go\pkg\mod\gopkg.in\zeromq\goczmq.v4@v4.1.0\auth.go:4:10: fatal error: czmq.h: No such file or directory
    4 | #include "czmq.h"
      |          ^~~~~~~~
compilation terminated.

Windows and Golang version: Windows 10-x64 and Go 1.17.3

go version
go version go1.17.3 windows/amd64

I'm a beginner in golang, please help me in this field.

答案1

得分: 1

经过多次尝试,我发现了如何在Go中安装zmq

首先,我尝试了另一个GCC软件。从https://www.msys2.org/下载软件并安装在C:\msys64上。

然后将C:\msys64\mingw64\bin添加到Windows的PATH环境变量中。

然后逐个运行以下命令(在执行命令之前,请查看解决方案底部的2022年11月5日更新)。

pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S base-devel gcc vim cmake
pacman -S mingw-w64-x86_64-libsodium
pacman -S mingw-w64-x86_64-zeromq

最后,运行Go安装命令:

go get github.com/pebbe/zmq4

完成。
现在看起来很简单 在安装Golang ZMQ(ZeroMQ)时遇到问题 – 致命错误:czmq.h:没有该文件或目录

英文:

After many tries, I discovered how to install zmq for Go.

First of all, I tried another GCC software. Software downloaded from https://www.msys2.org/ and installed on C:\msys64.

Then add C:\msys64\mingw64\bin to the PATH environment variable of the windows.

Then run the following commands one by one (before executing the commands please see the update 5 Nov 2022 at the bottom of this solution).

pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S base-devel gcc vim cmake
pacman -S mingw-w64-x86_64-libsodium
pacman -S mingw-w64-x86_64-zeromq

Finally, run the Go install command:

go get github.com/pebbe/zmq4

Finished.
Now it seems easy 在安装Golang ZMQ(ZeroMQ)时遇到问题 – 致命错误:czmq.h:没有该文件或目录


Update 5 Nov 2022

By updating MSYS some errors were raised in this solution:

> David Macek <david.macek.0@gmail.com> is unknown trust

Based on this page, before running the pacman command, its configurations should edit.

To work correctly, edit the C:\msys64\etc\pacman.conf file and edit the line SigLevel to SigLevel = Never.

huangapple
  • 本文由 发表于 2022年1月25日 04:17:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/70839950.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定