简体   繁体   中英

Can I use 32bit dll or exe in 64bit python?

When I use CDLL to call 32bit dll in 32bit python, it works well. But unfortunatelly in my 64bit win7 os only installs 64bit python, when calling it turns: it is not a effective win32 app!

Can I use 32bit dll or exe in 64bit python? Or I have to install 32bit python instead?

64-bit EXEs cannot load 32-bit DLLs. (And vice versa: 32-bit EXEs cannot load 64-bit DLLs.) After all, they can't agree on the size of a pointer -- what would happen if the EXE allocated memory above the 4GB boundary and wanted to pass that pointer to the 32-bit DLL?

You'll have to either:

  1. Make a 64-bit version of your DLL;
  2. Use a 32-bit version of Python; or
  3. Host the DLL in a separate (32-bit) EXE, and use some form of inter-process communication to talk to it from your 64-bit Python process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM