schall_l
21st April 2008, 15:51
I have a similar request as Merry in a previous post today.
As this post was not answered I would like to be a bit more precise at least concerning my problem.
Let's say I am writing an application using QT4 that is supposed to use the driver dll from a third vendor hardware device. The device comes with a .dll file, with a .lib file and with a .h file describing the driver interface. I have no possibility to recompile the .dll and the .lib files as they come as is, with the hardware device.
For example let's take a fictive USB device implementing some leds. The driver allows the driving of it led's and comes with 3 files: ledviausb.dll, ledviausb.lib and ledviausb.h (see attachement)
My question is to know how to integrate this into my QT4 project ?
First I suppose that I would need to specify the .lib file in the project file ?
LIBS += driver/ledviausb.lib
INCLUDEPATH += driver
Than I would need to address it from my application ?
#include "ledviausb.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
CLEDviaUSB*test = new CLEDviaUSB();
test->OpenDriver(0);
test->SwitchOnLed(0,1);
test->SwitchOnLed(0,2);
return 0;
}
Do I need to rewrite the .h file to follow some QT4 specifications, because currently the compilation would give me something like:
1>LINK : debug\dll_test_app.exe not found or not built by the last incremental link; performing full link
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: short __stdcall CLEDviaUSB::SwitchOnLed(unsigned char,short)" (__imp_?SwitchOnLed@CLEDviaUSB@@QAGFEF@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: short __thiscall CLEDviaUSB::OpenDriver(unsigned char)" (__imp_?OpenDriver@CLEDviaUSB@@QAEFE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CLEDviaUSB::CLEDviaUSB(void)" (__imp_??0CLEDviaUSB@@QAE@XZ) referenced in function _main
1>debug\dll_test_app.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\tmp\canmonitor\lab\dll_test_app\debug\BuildLog. htm"
As this post was not answered I would like to be a bit more precise at least concerning my problem.
Let's say I am writing an application using QT4 that is supposed to use the driver dll from a third vendor hardware device. The device comes with a .dll file, with a .lib file and with a .h file describing the driver interface. I have no possibility to recompile the .dll and the .lib files as they come as is, with the hardware device.
For example let's take a fictive USB device implementing some leds. The driver allows the driving of it led's and comes with 3 files: ledviausb.dll, ledviausb.lib and ledviausb.h (see attachement)
My question is to know how to integrate this into my QT4 project ?
First I suppose that I would need to specify the .lib file in the project file ?
LIBS += driver/ledviausb.lib
INCLUDEPATH += driver
Than I would need to address it from my application ?
#include "ledviausb.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
CLEDviaUSB*test = new CLEDviaUSB();
test->OpenDriver(0);
test->SwitchOnLed(0,1);
test->SwitchOnLed(0,2);
return 0;
}
Do I need to rewrite the .h file to follow some QT4 specifications, because currently the compilation would give me something like:
1>LINK : debug\dll_test_app.exe not found or not built by the last incremental link; performing full link
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: short __stdcall CLEDviaUSB::SwitchOnLed(unsigned char,short)" (__imp_?SwitchOnLed@CLEDviaUSB@@QAGFEF@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: short __thiscall CLEDviaUSB::OpenDriver(unsigned char)" (__imp_?OpenDriver@CLEDviaUSB@@QAEFE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CLEDviaUSB::CLEDviaUSB(void)" (__imp_??0CLEDviaUSB@@QAE@XZ) referenced in function _main
1>debug\dll_test_app.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\tmp\canmonitor\lab\dll_test_app\debug\BuildLog. htm"