Building a dll with Go 1.7
In this article, we will explore the possibility of building a dll against Go v1.7 under Windows.
Question:
Is there a way to build a dll against Go v1.7 under Windows?
Background:
Attempts to build a dll using the classic approach:
go build -buildmode=shared main.go
Result in the following error:
-buildmode=shared not supported on windows/amd64
Answer:
As of Go 1.10, the -buildmode=c-shared flag is now supported on Windows.
Updated Command:
To compile a DLL in Go 1.10 or later, use the following command:
go build -o helloworld.dll -buildmode=c-shared
Compatibility:
Note that the headers generated by Go are compatible with GCC, which may limit the compatibility of your DLL with other programming environments.
Additional Information:
For more in-depth information, refer to the following resources:
The above is the detailed content of Can Go 1.7 Build DLLs on Windows?. For more information, please follow other related articles on the PHP Chinese website!