"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Can Go 1.7 Build DLLs on Windows?

Can Go 1.7 Build DLLs on Windows?

Published on 2024-12-22
Browse:764

Can Go 1.7 Build DLLs on Windows?

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:

  • [Release Notes - Go 1.10](https://golang.org/doc/go1.10#compiler)
  • [Google Group Discussion](https://groups.google.com/forum/#!topic/golang-dev/ckFZAZbnjzU)
Latest tutorial More>

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