Home >Backend Development >Golang >Go ZeroMQ: Linker issues when trying to build VS Code on Windows
php editor Zimo encountered a linker problem when trying to use Go ZeroMQ on a Windows system when building VS Code. This problem occurs during compilation and causes the build to fail. In order to solve this problem, the editor conducted a series of investigations and attempts, and finally found a solution. This article will introduce the background and causes of this linker problem in detail, and share the solution, hoping to help other developers solve similar problems quickly.
In short, I want to do the following: Use https://github.com/pebbe/zmq4 and run a simple example like hello world in vs code on windows. When building, I get these types of errors
<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/[email protected]/wrappers_windows.go:27: undefined reference to `__imp_zmq_bind'
What I've done so far:
vcpkg.exe install libzmq:x64-windows
(Default is a 32-bit install, this is the first time I did it by mistake. I hope there aren't any leftovers causing problems. )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'
463db8000df5bbb698520c066bc41f09\tdm-gcc-64\bin
, 463db8000df5bbb698520c066bc41f09\vcpkg\installed\x64-windows\lib
and < ;windows homedir>\vcpkg\installed\x64-windows\include
to %path% environment variableI am using go version go1.18.4 windows/amd64 and vs code 1.74.1 on windows 10 enterprise.
I don't know what to try next, so any tips are greatly appreciated.
I used the wrong syntax for the linker flags. https://github.com/pebbe/zmq4 Put me on the wrong path. It should be CGO_LDFLAGS='-L d56d737ffc497ec92db023dcb17d6ed5/vcpkg/installed/x64-windows/lib -l libzmq-mt-4_3_4'
The above is the detailed content of Go ZeroMQ: Linker issues when trying to build VS Code on Windows. For more information, please follow other related articles on the PHP Chinese website!