[英]Go ZeroMQ: Linker problem when trying to build in VS Code on Windows
In short, I want to do the following thing: Use https://github.com/pebbe/zmq4 and run a simple example, like hello world in VS Code on Windows. When building, I get these kinds of errors简而言之,我想做以下事情:使用https://github.com/pebbe/zmq4并在 Windows 上运行一个简单的示例,例如 VS Code 中的hello world 。构建时,我遇到了这些错误
<Windows Homedir>/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b299\_x008.o: in function `zmq4_bind':
<GOPATH>/pkg/mod/github.com/pebbe/zmq4@v1.2.9/wrappers_windows.go:27: undefined reference to `__imp_zmq_bind'
What I did so far:到目前为止我做了什么:
vcpkg.exe install libzmq:x64-windows
(default is 32 bit installation, which I did first by mistake. I hope there is no leftover from this somewhere that's causing problems.)vcpkg.exe install libzmq:x64-windows
(默认是 32 位安装,我首先错误地安装了它。我希望这个地方没有遗留问题。)go env -w CGO_CFLAGS='-I <Windows Homedir>\vcpkg\installed\x64-windows\include'
go env -w CGO_LDFLAGS='-LD:<Windows Homedir>\vcpkg\installed\x64-windows\lib -L:libzmq-mt-4_3_4.lib'
<Windows Homedir>\TDM-GCC-64\bin
, <Windows Homedir>\vcpkg\installed\x64-windows\lib
and <Windows Homedir>\vcpkg\installed\x64-windows\include
to %Path% environment variable<Windows Homedir>\TDM-GCC-64\bin
, <Windows Homedir>\vcpkg\installed\x64-windows\lib
和<Windows Homedir>\vcpkg\installed\x64-windows\include
到 %Path% 环境变量I'm using Go version go1.18.4 windows/amd64 and VS Code 1.74.1 on Windows 10 Enterprise.我在 Windows 10 Enterprise 上使用 Go 版本 go1.18.4 windows/amd64 和 VS Code 1.74.1。
I have no clue what to try next, so any hints are very much appreciated.我不知道接下来要尝试什么,所以非常感谢任何提示。
I was using a wrong a wrong syntax for the linker flags.我对 linker 标志使用了错误的语法。 https://github.com/pebbe/zmq4 has lead me on a wrong track.
https://github.com/pebbe/zmq4让我误入歧途。 It should be
CGO_LDFLAGS='-L <Windows Homedir>/vcpkg/installed/x64-windows/lib -l libzmq-mt-4_3_4'
应该是
CGO_LDFLAGS='-L <Windows Homedir>/vcpkg/installed/x64-windows/lib -l libzmq-mt-4_3_4'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.