Search code examples
qtvisual-studio-2012qglviewer

unresolved external symbol "__declspec(dllimport)


I am trying to get libqglviewer to work in visual studio, I have installed Qt5.2.0 64-bit for VS 2012.

I have added the include directories for QGLViewer and QT in the project settings together with the lib-directory and the lib-files for qt (both Release and Debug).

I have a simple example code to test it:

main.cpp
#include "simpleViewer.h"
#include <qapplication.h>

int main(int argc, char** argv)
{
 // Read command lines arguments.
 QApplication application(argc,argv);

 // Instantiate the viewer.
 /* Viewer viewer;


 viewer.setWindowTitle("simpleViewer");


// Make the viewer window visible on screen.
 viewer.show();

// Run main loop.
 return application.exec();*/
}


simpleViewer.h
#include <QGLViewer/qglviewer.h>

class Viewer : public QGLViewer
{
protected :
virtual void draw();
virtual void init();
virtual QString helpString() const;
};

When I try to compile it I get

 main.obj : error LNK2001: unresolved external symbol "_declspec(dllimport) public: virtual class QString __cdecl QGLViewer::mouseBindingsString(void)const " (__imp_?mouseBindingsString@QGLViewer@@UEBA?AVQString@@XZ)

Plenty of them. I have looked around, but I cannot understand what the error is.

If I comment out everything except QApplication(argc,argv) it compiles, but if I uncomment Viewer viewer I get a lot of errors. I don't see what is missing since it compiles when I only use QApplication.

It feels like there is something missing with the linking, but I have added all .lib files I can find.

One thing is that if I download the libQGLViewer and run the following

qmake -t vclib QGLViewer.pro -spec win32-msvc2013

and then opens it in Visual Studio 2013 ( I changed today without success) it builds and generates the QGLViewer2.dll files as it should according to the instruction on libQGLViewers homepage. But if I try the simpleViewer example it gives the same problems again.


Solution

  • Edit:

    By re-installing everything qt and qt visual studio add-in again, for some reason the add-in searched for old versions of qt, when that was fixed I could open an example from libQGLViewer and immitate all includes and links I could finally get it to work.