From the basic test program.,.
package main /* #include <stdio.h> static void test() { printf("hello world"); } */ import "C" func main() { C.test(); }
I do "cgo hello_cgo.go" and get:
_cgo_.o _cgo_defun.c _cgo_gotypes.go hello_cgo.cgo1.go hello_cgo.cgo2.c
How do I go from compiling here to exe?
Try using go make files. Create a makefile like
# Makefile CGOFILES=test.go TARG=test include $(GOROOT)/src/Make.$(GOARCH) include $(GOROOT)/src/Make.pkg
Running make will create a file _obj/test.athat you will need to associate with 6lor similar.
_obj/test.a
6l
Update for go1:
$ cat foo.go package main // #include <stdio.h> // static void test() { printf("Hello, world\n"); } import "C" func main() { C.test() } $ go build foo.go $ ./foo Hello, world
Source: https://habr.com/ru/post/1744432/More articles:What is an entity? Why is it called Entity? - entityProper use of HttpRequestInterceptor and CredentialsProvider when performing preauthentication using HttpClient - javaExt-GWT/GXT (не так) Простая макетная проблема? - gwtAjax call with jQuery in ASP.NET MVC does not pass parameters - jquerySubclassification of NSArrayController to limit the size of located objects - cocoaLimiting the number of objects in NSArrayController - objective-cpython xml.dom.minidom.Attr question - pythonApache POI Excel Comment - javaDisplay variable with erb - variablesProblems displaying maxWidth on Google Map - google-mapsAll Articles