I need to call a certain function written in C in my python code using the ctypes library to call a shared object .so. So I followed this (apparently) simple guide.
the C file / function:
#include <stdio.h>
int square(int i) {
return i * i;
}
the python file:
from ctypes import *
so_file = "C:/PY2C/my_functions.so"
my_functions = CDLL(so_file)
print(type(my_functions))
print(my_functions.square(10))
print("done")
and I got the following errors:
File "C:\PY2C\calling_c_functions.py", line 5, in <module>
my_functions = CDLL(so_file)
File "C:\Users\myname\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 369, in __init__
self._handle = _dlopen(self._name, mode)";
OSError: [WinError 193] %1 non è un'applicazione di Win32 valida
Why python can't read the .so shared object? How can I solve this simple task?