duanmeng2842 2018-08-21 06:02
浏览 223

在Linux中使用.so的Golang

How can I load .so on Linux?

On Windows I do something like this:

h, e = syscall.LoadLibrary("name.dll") 
    if e != nil {
        log.Fatal(e)
    }
    defer syscall.FreeLibrary(h)

Is it possible to do it on Linux with .so library?

proc, e := syscall.GetProcAddress(h, processName) //One of the functions in the DLL
if e != nil {
    log.Fatal("errror:", e, processName)
}
pid, _, _ := syscall.Syscall6(uintptr(proc), uintptr(paramSize), a1, a2, a3, 0, 0, 0) //handler, countParam, param, 0 // zawiera jakiegoś print "Hello World" - value
fmt.Println(processName, pid)

I want to get the function(process) address and use it to call in syscall.Syscall6.

There is answer with using CGo but it is not complete and doesn't explain how to void this function and pass param to it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器