Windows下VS Code编译Go ZeroMQ项目遇链接器错误求助
问题:Windows下VS Code使用zmq4库编译报错(undefined reference to
__imp_zmq_bind) 我在Windows系统的VS Code中尝试使用zmq4库运行类似hwclient.go的简单示例时,编译出现以下错误:
<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'
我已经执行了以下操作:
- 安装Visual Studio(满足vcpkg安装要求)
- 使用
vcpkg.exe install libzmq:x64-windows安装libzmq(最初误装32位版本,已纠正) - 在VS Code的PowerShell终端中设置Go环境变量:
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' - 安装TDM-GCC
- 将
<Windows Homedir>\TDM-GCC-64\bin、<Windows Homedir>\vcpkg\installed\x64-windows\lib和<Windows Homedir>\vcpkg\installed\x64-windows\include添加到%Path%环境变量
我的环境信息:
- Go版本:go1.18.4 windows/amd64
- VS Code版本:1.74.1
- 系统:Windows 10企业版
目前找不到解决方向,恳请提供可行的解决思路。
内容的提问来源于stack exchange,提问作者Joris Ticozzelli
相关产品推荐
相关产品推荐

