//LibHelloWorld.h void SayHelloWorld(char * name); //HelloWorld.c #include <stdio.h> #include "LibHelloWorld.h" void SayHelloWorld(char * name){ printf("Hello,%s!\n",name); }
gcc -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"HelloWorld.d" -MT"HelloWorld.d" -o"HelloWorld.o" "../HelloWorld.c"
gcc -shared -o"libLibHelloWorld.so" ./HelloWorld.o
//myCGO.go package main /* #cgo LDFLAGS: -L./ -lLibHelloWorld #include "LibHelloWorld.h" */ import ( "C" ) func main() { C.SayHelloWorld(C.CString("Azik")) }
OK!Finish!