创建C DLL并在Golang中使用它?

I want to create DLL in C and use it in Golang.

I used this tutorial to generate dll : helloWorld.h

#include<stdio.h>
void __stdcall __declspec(dllexport) hello();

helloWorld.c

#include<stdio.h>
#include "helloWorld.h"
__stdcall void hello()
{
    printf("Hello World !!");
}

I used this in command Prompt to compile it

g++ -c helloWorld.c
g++ -shared -o helloWorld.dll helloWorld.o -Wl,--out-implib,libhelloWorld.a

I was able to use the generated dll in this C code , named as example.c :

#include<stdio.h>
#include "helloWorld.h"
int main()
{
    hello();
}

and compile it using

g++ -c example.c
g++ -o example.exe example.o -L. -lhelloWorld

But while using the DLL in Golang , i am getting error , please help me

test.go

package main 

/*
#cgo LDFLAGS: -L. -lhelloWorld
#include "helloWorld.h"
*/
import "C"

func main(){

    C.hello()
}

Error :

# command-line-arguments
C:\Users\kumarmoh\AppData\Local\Temp\go-build544493490\b001\_x002.o: In function `_cgo_525f579e070a_Cfunc_hello':
/tmp/go-build/cgo-gcc-prolog:40: undefined reference to `hello'
collect2.exe: error: ld returned 1 exit status 

error image

Other info :

  1. go version go1.11 windows/amd64

  2. 64-bit OS , x64-based processor , Windows 10

  3. I tried creating dll in Visual studios and it gave me error as explained here .