I make a simple Go file that exports a function
package main
import "C"
import "fmt"
//export PrintBye
func PrintBye() {
fmt.Println("From DLL: Bye!")
}
func main() {
// Need a main function to make CGO compile package as C shared library
}
and build it
go build -buildmode=c-shared main.go
have a problem
command-line-arguments
C:\Program Files\GO\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 C:\Users****\AppData\Local\Temp\go-link-293444627\go.o: file not recognized: file format not recognized collect2.exe: error: ld returned 1 exit status
in the MinGW ,I install some basic package
mingw-developer-toolkit-bin
mingw32-base-bin
mingw32-gcc-g++-bin
mingw32-gcc-objc-bin
msys-base-bin