Home >Backend Development >Golang >Can Go 1.7 Build DLLs on Windows?

Can Go 1.7 Build DLLs on Windows?

Susan Sarandon
Susan SarandonOriginal
2024-12-28 06:40:14676browse

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)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn