Reputation: 214
I am trying to call go lang function from python when I call my python program I am seeing the following error. I am referring to the Go to pythn link.
Python Program
from ctypes import *
def call_go_function():
lib = cdll.LoadLibrary("./awesome.so")
lib.Add.argtypes = [c_longlong, c_longlong]
print( lib.Add(12,99))
call_go_function()
Go Program
package main
import "C"
import (
"sync"
)
var count int
var mtx sync.Mutex
//export Add
func Add(a, b int) int { return a + b }
func main() {}
Upvotes: 1
Views: 7991
Reputation: 11
from ctypes import *
lib = cdll.LoadLibrary("./func.so")
r=lib.fun(10,20)
print(r)
package main
import "C"
//export fun
func fun(x int,y int) int{
return x+y
}
func main(){}
>go build -o func.so -buildmode=c-shared func.go
>python test.py
30
Upvotes: 1
Reputation: 7373
From the Python path it looks like this is a 32-bit Python version. You cannot mix 32-bit and 64-bit user-space code.
So I guess you need to either:
Upvotes: 2