'Project depends on .dll but there is no .lib
I'm moving a Qt 5 based project which depends on external .dll to another windows laptop, project is build with qmake. In other projects I used to see a .lib corresponding to the .dll but this project seems to build fine without one. My understanding is that the .lib is necessary to build the project while the .dll will be used at runtime.
Is it possible not to have a .lib? If so my understanding of how build process works is missing something, right?
On a qmake based project I used to see:
INCLUDEPATH += include
LIBS += -Lthelibfile
Where INCLUDEPATH will point to .h files and LIBS will point to .lib file.
In one of the .cpp files included I see var = LoadLibrary(L'somefile.dll'). Which is something I was not used to see in other projects.
Should I understand this as loading a .dll at runtime? And because of this its not necessary to have the corresponding .lib at build time?
Solution 1:[1]
Qt C++ code:
#include "project.h"
typedef int ( *PROJECT_FUNC )( void );
int MyFunc()
{
QLibrary dll;
dll.setFileName( "c:/project/project.dll" );
if ( !dll.load() ) {
throw "Failed to load project.dll.";
}
int ret = 0;
if ( dll.isLoaded() ) {
auto func = ( PROJECT_FUNC )dll.resolve( "ProjectFunc" );
if ( func != nullptr ) {
ret = func();
}
}
return ret;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Allen ZHU |
