未解析的外部符号 "__declspec(dllimport) [英] unresolved external symbol "__declspec(dllimport)

查看:22
本文介绍了未解析的外部符号 "__declspec(dllimport)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 libqglviewer 在 Visual Studio 中工作,我已经为 VS 2012 安装了 Qt5.2.0 64 位.

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

我在项目设置中添加了 QGLViewer 和 QT 的包含目录以及 qt 的 lib 目录和 lib 文件(发布和调试).

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.

如果我注释掉除 QApplication(argc,argv) 之外的所有内容,它会编译,但是如果我取消对 Viewer viewer 的注释,我会收到很多错误.我没有看到缺少什么,因为它在我只使用 QApplication 时编译.

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.

感觉链接中缺少一些东西,但我已经添加了我能找到的所有 .lib 文件.

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

一件事是,如果我下载 libQGLViewer 并运行以下内容

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

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

然后在 Visual Studio 2013 中打开它(我今天更改没有成功)它会根据 libQGLViewers 主页上的说明构建并生成 QGLViewer2.dll 文件.但是,如果我尝试使用 simpleViewer 示例,它又会出现同样的问题.

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.

推荐答案

通过重新安装所有 qt 和 qt Visual Studio 插件,出于某种原因,插件搜索了旧版本的 qt,修复后我可以从 libQGLViewer 打开一个示例并模仿所有包含和链接我终于可以让它工作了.

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.

这篇关于未解析的外部符号 &quot;__declspec(dllimport)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆