Andreas N
Andreas N

Reputation: 834

Compiled app wants to load DLL from absolute path

Hello to my little DLL hell!

I have written an application based on C++/Qt and it also uses QCA - the Qt Cryptographic Architecture. From there the basic stuff is available via libqca.dll, more stuff like decryption is provided by separate plugins. QCA is compiled via cmake, make, make install. It installes the DLLs and a mkspec feature in the Qt installation directory.

After compiling QCA and then my application, it ran fine. But when I installed this app on another computer without any development stuff, the additional libqca-ossl.dll providing AES decryption was not loaded during runtime.

Dependency Walker revealed, that my app is trying to load the latter DLL from here:

C:/Qt/4.8.4/plugins/crypto/libqca-ossl.dll

This is the path, where it was installed on the development computer. Clearly, this path doesn't exist on other computers. When I created this path on that other machine and put the DLL inside, it is loaded. Both DLLs, that are needed, already reside in the EXE's directory and should be found there.

So it seems to me, the DLLs absolute install path got somehow hardcoded into the application. How can I make my app find the DLL, that's sitting next to the EXE?

Upvotes: 1

Views: 343

Answers (1)

Harry Johnston
Harry Johnston

Reputation: 36318

See "How does it work?" on the QCA project home page:

Crypto functionality is determined during runtime, and plugins are loaded from the ‘crypto’ subfolder of the Qt Library Paths.

So the behaviour you describe is as-expected.

To make it work, you will need to either change the Qt library paths folder at runtime, or explicitly insert the provider you want using QCA::InsertProvider, as described in the documentation. The latter is probably preferable as it is more localized. Changing the library paths might conceivably introduce side-effects into the rest of your application, or conflict with other third-party libraries.

Upvotes: 1

Related Questions