简体   繁体   中英

PySide DLL loading conflict within a C++ / Qt application

I have a C++ application which uses the Core, GUI and Network modules of Qt 4.x. It calls python callbacks when the user does certain actions, the point being that the user can customize these callbacks by writing python code.

When I try to import the QtNetwork module from PySide within a callback like this :

from PySide import QtNetwork

I get the following error :

dll load failed : the specified procedure could not be found

Note that I don't get the error when I import the QtCore and QtGui modules.

I used dependency walker to try to figure out the issue.
When the application starts, it loads QtCore4.dll , QtGui4.dll and QtNetwork4.dll which are the C++ Qt DLLs placed in my application's directory.
When I trigger a callback to my python code that imports QtNetwork from PySide, it loads QtNetwork.pyd and then gives me the error :

LoadLibraryExA("C:\\Dev\\Python27\\lib\\site-packages\\PySide\\QtNetwork.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: the specified procedure could not be found (127).

My dependency tree of QtNetwork.pyd :
QtNetwork.pyd的依赖关系树 seems to indicate that it uses the already loaded C++ DLLs instead of the PySide ones. I guess that is because their name are identical.
Is there a way to make it load the right DLLs (the ones in the c:\\dev\\python27\\lib\\site_package\\pyside\\ directory )?
Also, why doesn't this conflict matters with QtCore and QtGui ?

First of all, check if your QTNETWORK4.DLL satisfy requirements:

  • is for your architecture
  • have the same version as your Qt libs, using witch you compile your program
  • is compiled by the same compiler

Best way is just copy libs you need from Qt's bin directory to your build directory.

So, I think this conflict matters only with QTNETWORK4.DLL because this lib has some other version (don't satisfy requirements above).

The way to make it load right DLLs is to add to your path environment variable path to your Qt's bin directory, and delete DLLs from your programs directory -- so, it can find needed libs from path .

Hope it helps!

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