liewl
liewl

Reputation: 4071

Loading library with dependency with QLibrary

Suppose I have two libraries, A.dll and B.dll. The library A depends on B. I want to load A into my project.

My project is in C:/Project. If I keep both A.dll and B.dll in C:/Project, I can load A with:

QLibrary lib("A"); 
lib.load();

This works fine. load() will return false if B.dll isn't in C:/Project, though.

The problem is I want to keep both A.dll and B.dll in C:/Project/lib. But when I move both libs to that location and try to load:

QLibrary lib("C:/Project/lib/A");
lib.load();

It fails. But this works if I keep A.dll in C:/Project/lib and B.dll in C:/Project.

How can I keep both libs in C:/Project/liband have A.dll load successfully?

Edit: the error message I get is "Cannot load library C:/Project/lib/A . The specified module could not be found."

Upvotes: 2

Views: 4331

Answers (2)

Ispas Claudiu
Ispas Claudiu

Reputation: 2008

You should add into your system environment the path to C:/Project/lib, or from the Projects tab into your QT Creator edit the Path variable(add the path to your libraries)

Upvotes: 0

DmitryARN
DmitryARN

Reputation: 648

Try using SetDllDirectory, see http://msdn.microsoft.com/en-us/library/ms686203%28VS.85%29.aspx

Upvotes: 2

Related Questions