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:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3