Reputation: 61
I'm trying to link a library to my project but keep having that :
LNK2019: unresolved external symbol __imp_GetLibraryVersion referenced in function main
My .pro file looks like this :
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
unix|win32: LIBS += -L$$PWD../../Libs/ -ldrivers
INCLUDEPATH += $$PWD/../../Headers
I have one source file that looks like this :
#include "drivers.h"
void main()
{
GetLibraryVersion();
}
That is obviously just a test project. The lib is in the Libs directory and the header file in the Headers directory.
The header file in question looks like this, but with a bunch of other functions:
#ifdef _WIN32
#ifndef DLL
#define DLL _declspec(dllimport)
#endif
#else
#define DLL
#define __stdcall
#endif
#ifdef __cplusplus
extern C
{
#else
#typedef int bool
#endif
DLL char * __stdcall GetLibraryVersion(void);
...
#ifdef __cplusplus
}
#endif
I'm using Qt 5.1.0 with msvc2012 compiler on a windows 7 x64 and the project is compiled for 64bits.
The strange thing is, it works perfectly with Visual Studio 2012 with the same source file by just adding main as the entry point and adding the library drivers.lib to the project (no precompiled headers or anything).
Upvotes: 2
Views: 1760
Reputation: 61
The dll was for 32 bits and my project was for 64 bits. Just changed my project settings to 32 bits and it worked.
Upvotes: 2