PDA

View Full Version : Link a .dll library to a Qt project



n3500
27th July 2012, 08:03
Hi !

I am actually working on a project which enables connection to a datalogger Campbell.
Campbell provides a simplepb.dll to communicate with datalogger, and I would like to use it in my project.
You can download it here. (http://www.qtfr.org/img/members/146097/DLL.rar)
I put this dll and the header in a DLL directory located on C:

I changed the .pro file into:

INCLUDEPATH += C:/DLL
LIBS += -LC:/DLL -lsimplepb -lcoralib3d

The header:

#ifndef FUNCTIONS_H
#define FUNCTIONS_H

#include "simplepb.h"

void test();

#endif // FUNCTIONS_H

The .cpp:

#include "Functions.h"

void test()
{
OpenPort(1,9600); //Function of simplepb.dll
}

After building with Mingw, I obtain every time the same error: ..\TestDll\Fonctions.cpp:5: erreur : undefined reference to `OpenPort@8'.

If someone has an idea to fix it !

TY ;)

high_flyer
27th July 2012, 11:39
The dll is not enough.
You need the *.lib file which holds the symbol information.
If you don't have, you could use GetProcAdresss() with the function signatures you have in your header. (under windows).
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx

n3500
27th July 2012, 12:31
Hi !

Thanks for your help !

It's working !!!!! I found the .lib and droped it in the same directory =D

Thanks a lot !