QT Release build DLL procedure entry point error

2019-01-26 05:25发布

问题:

I built an application in Qt Creator that does some image processing with CImg. It runs fine when I run it from the inside IDE, but if I try to launch it from its directory, it throws the following error.

The procedure entry point ??4QString@@QAEAAV0@$$QAV0AAZ could not be located 
in the dynamic link library QtCore4.dll

Everything points to having multiple version of the DLLs installed. I found my Xilinx IDE uses the Qt libraries, but the DLLs in question are the same version. I'm not really a software guy, and at a loss here.

回答1:

Even if the library version is the same they may be non compatible. For instance they were compiled with different configurations, like with or without STL support, OpenGL, SQL drivers...

The simplest way to fix it should be to move Qt SDK's path at beginning of PATH environment variable. This way whenever you run an executable that requires Qt libraries it will load the ones shipped with SDK (the first ones found in PATH), unless there are already copies of QtCore4.dll, QtGui4.dll... in the executable's directory. For this reason if you redistribute your application you might also have to ship the libraries in its directory.

Another option is static linking, but you will be required to provide source code under the (L)GPL licence.



回答2:

Use DependencyWalker to list from where qtcore4.dll is loaded. I had the same problem - DependencyWalker showed me that qtcore4.dll was loaded from c:\windows\system32 - but there was no qtcore4.dll in this folder.

Beware: On Windows 7 64 Bit c:\windows\SysWOW64 is "mapped" as c:\windows\system32. And in this folder I found the dll - I renamed the dll and the problem was solved.

See this answer here: Qt fresh Gui application crashes on startup, faulting at QtCore4.dll



回答3:

Static linking the libraries eliminates the problem.