[英]OSError: [WinError 193] %1 is not a valid Win32 application - python
python file python 文件
import ctypes
from numpy.ctypeslib import ndpointer
#lib = ctypes.CDLL("C:\\Users\\Ali\\Desktop\\test9\\a.dll")
lib = ctypes.CDLL("C:\\Users\\Ali\\Desktop\\test9\\a.dll")
#lib.function.restype = ndpointer(dtype=ctypes.c_int, shape=(4000,3),flags='C')
lib.function.restype = ndpointer(dtype=ctypes.c_int, shape=(100000000,3),flags='C')
#
res = lib.function()
print(res)
c file(dll) c 文件(dll)
int (*function(void))[3] {
clock_t begin = clock();
// allocate an array of 5 arrays of 5 int
int (*information)[3] = malloc(100000000 * sizeof(*information));
// initialize all 5 rows to identical vectors { 0, 1, 2, 3, 4 }
for (int k = 0; k < 100000000; k++) {
for (int j = 0; j < 3; j++) {
information[k][j] = j;
}
}
clock_t end = clock();
double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%f\n", time_spent);
return information;
}
When I try to use the dll it gives me this error even though I'm sure mingw64 is installed当我尝试使用 dll 时,即使我确定安装了 mingw64,它也会给我这个错误
Is my problem from c script?我的问题来自 c 脚本吗? thank you
谢谢你
My problem was with the compilation code im used gcc -shared -o a.dll main.c instead of gcc -c -fPIC main.c -o a.dll My problem was with the compilation code im used gcc -shared -o a.dll main.c instead of gcc -c -fPIC main.c -o a.dll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.