I'm having troubles with using of external library, lets start from beginning. I have some library trans2quik, wich consists of 3 files: trans2quik .dll/.lib/.h
So, I use Qt5.2, MSVC 2012 x64, win7. I create simple qt widget application, and link library, using "Add library" wizard, for generating LIBS, INCLUDEPATH, ect in my pro file. Then, when I call any function, I get unresolved extenal symbol error:
widget.obj:-1: error: LNK2019: unresolved external symbol __imp_TRANS2QUIK_CONNECT in function "public: __cdecl Widget::Widget(class QWidget *)" (??0Widget@@QEAA@PEAVQWidget@@@Z)
The code follows:
PRO file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = bot_test
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
win32: LIBS += -L$$PWD/ -lTRANS2QUIK
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
widget.h file:
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <Windows.h> //For LPSTR and DWORD
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
//Some vars for lib's function
LPSTR connectionParams;
LPSTR errorMsg;
DWORD errorMsgSize;
long *errorCode;
};
#endif // WIDGET_H
widget.cpp file:
#include "widget.h"
#include "trans2quik_api.h"
#pragma comment(lib, "TRANS2QUIK.lib")
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
TRANS2QUIK_CONNECT(connectionParams, errorCode, errorMsg, errorMsgSize);
}
So, the .lib and lib's .h files are in projects directory and LIB+= and INCLUDEPATH+= were generated by QtCreator, so I beliave it's not a problem. Hope for any halp, thank you in advance.
The problem is that you are trying to link againt a 32 bit trans2quik, whereas your application seems to be defined as 64 bit. Do not mix them. Either build 32 bit application, or use a 64 bit library.