是否有建立在Windows下對圍棋V1.7一個dll的方法嗎?建立一個DLL與圍棋1.7
我嘗試了經典
go build -buildmode=shared main.go
,但得到
-buildmode =共享不支持Windows/AMD64
更新 好吧,我有我的回答。對於那些有興趣誰: https://groups.google.com/forum/#!topic/golang-dev/ckFZAZbnjzU
是否有建立在Windows下對圍棋V1.7一個dll的方法嗎?建立一個DLL與圍棋1.7
我嘗試了經典
go build -buildmode=shared main.go
,但得到
-buildmode =共享不支持Windows/AMD64
更新 好吧,我有我的回答。對於那些有興趣誰: https://groups.google.com/forum/#!topic/golang-dev/ckFZAZbnjzU
go build -buildmode=c-archive github.com/user/ExportHello
====>將建立ExportHello.a
,ExportHello.h
以建於ExportHello.a
和再出口的功能Hello2.c
gcc -shared -pthread -o Hello2.dll Hello2.c ExportHello.a -lWinMM -lntdll -lWS2_32
== ==>將生成Hello2.dll
有一個在github上項目,該項目展示瞭如何創建一個DLL的基礎上,並感謝user7155193的答案。
基本上你使用GCC從golang生成的.a和.h文件構建DLL。
首先你要的是出口的函數(或更多)的簡單圍棋文件。
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
}
與編譯:
go build -buildmode=c-archive exportgo.go
然後你犯了一個C程序(goDLL.c)將在.H鏈接及以上
#include <stdio.h>
#include "exportgo.h"
// force gcc to link in go runtime (may be a better solution than this)
void dummy() {
PrintBye();
}
int main() {
}
編譯生成.a文件/鏈接DLL與GCC:
gcc -shared -pthread -o goDLL.dll goDLL.c exportgo.a -lWinMM -lntdll -lWS2_32
的goDLL.dll然後可以被裝載到另一個C程序中,一個FreePascal的/拉扎勒斯程序,或者你選擇的程序。
完整的代碼與加載DLL中的拉撒路/ FPC項目是在這裏: https://github.com/z505/goDLL
'-buildmode = shared'是一個圍棋共享庫,這會不會讓一個DLL反正。你最有可能正在尋找'buildmode = C-shared',雖然尚未制定對窗口着呢,你可以按照[問題#11058(https://golang.org/issue/11058) – JimB