简体   繁体   English

OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - python

[英]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.

相关问题 OSError: [WinError 193] %1 不是 Python 中的有效 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application in python OSError: [WinError 193] %1 不是有效的 Win32 应用程序 Python - OSError: [WinError 193] %1 is not a valid Win32 application Python Python 错误:OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - Python error: OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (Pandas) - OSError: [WinError 193] %1 is not a valid Win32 application (Pandas) OSError: [WinError 193] %1 不是 CTypes 中的有效 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application in CTypes OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - nltk - OSError: [WinError 193] %1 is not a valid Win32 application - nltk OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (LibTiff) - OSError: [WinError 193] %1 is not a valid Win32 application (LibTiff) 如何修复“OSError: [WinError 193] %1 不是有效的 Win32 应用程序” - How to fix"OSError: [WinError 193] %1 is not a valid Win32 application" Azure - numpy - OSError:[WinError 193]%1不是有效的Win32应用程序 - Azure - numpy - OSError: [WinError 193] %1 is not a valid Win32 application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM