不能使用
动态库头文件:myfuns.h
#pragma once

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

void fun1();

void fun2(int a);

int func3(void **b);

// others
动态库名:myfuns.so

  

项目简化结构:
|-project
|  |-lib
|  |  |-myfuns.so
|  |-include
|  |  |-myfuns.h
|  |-src
|  |  |-main.go
|  |-pkg
|  |-bin
go链接动态库:main.go
package main

/*
#cgo CFLAGS : -I../include
#cgo LDFLAGS: -L../lib -lmyfuns

#include "myfuns.h"
*/
import "C"

import (
    "fmt"
)

func main() {
    // 调用动态库函数fun1
    C.fun1()
    // 调用动态库函数fun2
    C.fun2(C.int(4))
    // 调用动态库函数fun3
    var pointer unsafe.Pointer
    ret := C.fun3(&pointer)
    fmt.Println(int(ret))
}
CFLAGSLDFLAGSimport "C"