Compile .dll files that can be run under 64-bit windows

1. To compile 64-bit GCC, select the mingw64 compiler.
Download address: https://sourceforge.net/projects/mingw-w64/, click Download directly, and then configure environment variables (the easiest and most trouble-free pro-test)
Insert picture description here
Compile command: gcc -m64 ./xx/xxx.c (path) ./xx/xxxx.c (path) -fPIC -shared -o xx.dll

  1. How to judge whether the compiled .dll file is 32-bit or 64-bit?

    Open the exe file (dll file) directly with Notepad or notepad++, there will be a lot of garbled characters, then you only need to find the two letters PE in the second paragraph, and d or L will appear not far behind. If it is d, it proves that the program is 64-bit; if it is L, it proves that it is 32-bit
    Insert picture description here

3. Possible errors: [WinError 193] %1 is not a valid Win32 application!

这个第一种可能是python程序是32位的,.dll是64位的。第二种可能是编译出来的.dll文件是32位的,python是64位的,俩者的版本不同。

解决方法:打开cmd,输入where python,会出现python目录,cd到该目录下,命令行输入python,进去会有显示是32位的还是64位的,如果是32位的,卸载重装

Guess you like

Origin blog.csdn.net/hc_1995/article/details/109380789