1、当vs2010编译qt时会出现以下错误:

1>------ 已启动全部重新生成: 项目: MyDialog, 配置: Debug Win32 ------
           1>生成启动时间为 2015/9/9 14:57:04。
           1>InitializeBuildStatus:
           1>  正在创建“Debug\MyDialog.unsuccessfulbuild”,因为已指定“AlwaysCreate”。
           1>CustomBuild:
           1>  Moc'ing LoginDlg.h...
           1>ClCompile:
           1>  LoginDlg.cpp
           1>  main.cpp
           1>  正在生成代码...
           1>LoginDlg.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall CLoginDlg::metaObject(void)const " (?         metaObject@CLoginDlg@@UBEPBUQMetaObject@@XZ)
           1>LoginDlg.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall CLoginDlg::qt_metacast(char const *)" (?qt_metacast@CLoginDlg@@UAEPAXPBD@Z)
           1>LoginDlg.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall CLoginDlg::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@CLoginDlg@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
           1>D:\VC++\QtT\MyDialog\\MyDialog.exe : fatal error LNK1120: 3 个无法解析的外部命令
           1>
           1>生成失败。
           1>
           1>已用时间 00:00:03.23
            ========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

2、出现以上错误的原因是由于在GeneratedFiles/Debug文件中缺少一个moc_XXX.cpp文件,如下图所示:

3、缺少的文件名是什么呢?那么首先要找到Q_OBJECT宏在那个头文件中,比如在上图中该宏在LoginDlg.h文件中,那么生成的文件时moc_LoginDlg.cpp,要生成此文件需要qt库中的一个moc.exe文件,如下图所示:

4、通过cmd进入到此目录中,然后执行:moc "D:\VC++\QtT\MyDialog\MyDialog\LoginDlg.h" -o "D:\VC++\QtT\MyDialog\MyDialog\moc_LoginDlg.cpp"

如下图所示:

5、然后会在D:\VC++\QtT\MyDialog\MyDialog\目录生成一个moc_LoginDlg.cpp文件,如下图所示:

6、将moc_LoginDlg.cpp文件拷贝到GeneratedFiles/Debug目录中,并在vs中添加该文件,如下图所示:

7、重新编译即可

vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject等错误的更多相关文章

  1. main.obj:-1: error: LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall CustomButton::metaObject(void)const " (?metaObject@CustomButton@@UBEPBUQMetaObject@@XZ)

    QTCreator 运行时报错 main.obj:-1: error: LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject cons ...

  2. error LNK2001: 无法解析的外部符号 "public: virtual long __stdcall CBaseFilter(转)

    原文转自 https://www.cnblogs.com/xiongjiaji/archive/2010/12/31/2476565.html 今天用VS2005编译DirectShow程序,发现出来 ...

  3. 虚函数 error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl

    在虚函数后面加一对大括号 #ifndef CAFFE_CONV_DW_LAYER_HPP_ #define CAFFE_CONV_DW_LAYER_HPP_ #include <vector&g ...

  4. 无法解析的外部符号 "public: virtual struct CRuntimeClass * _

    SetupPropertyPage.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct CRuntimeClass * __this ...

  5. error LNK2001: 无法解析的外部符号 "public: char * __thiscall

    error LNK2001: 无法解析的外部符号 "public: char * __thiscall CamPinPadCtrl::KeysConvert(unsigned long,ch ...

  6. C++工程编译之“error LNK2001: 无法解析的外部符号”

    今天一整天都在折腾“error LNK2001: 无法解析的外部符号”,就在头疼不已的时候,总算是找到问题原因了:各个动态链接库的编译方式必须统一才行,要不然很容易对库函数的引用产生冲突.简单来说就是 ...

  7. error LNK2001: 无法解析的外部符号 _IID_IDirectDraw7

    工程使用了DirectDraw,编译出错 error LNK2001: 无法解析的外部符号 _IID_IDirectDraw7 解决办法是吧dxguid.lib添加到工程中,把lib所在目录添加到工程 ...

  8. 无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号

    无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号 参考官方配置指南:http://glew.sourceforge.net/install.html 1. ...

  9. 引用rtmp编译报错:rtmp.obj : error LNK2001: 无法解析的外部符号 __imp__timeGetTime@0

    如题vs下引用librtmp的时候报错:rtmp.obj : error LNK2001: 无法解析的外部符号 __imp__timeGetTime@0 在link 里加入 winmm.lib 就可以 ...

随机推荐

  1. Gym 100971C 水&愚&三角形

    Description standard input/output Announcement   Statements There is a set of n segments with the le ...

  2. python获取目录下文件夹名称

    path = '/opt' dirs = os.listdir(path) for dir in dirs: print dir

  3. iOS 初始化(init、initWithNibName、initWithCoder、initWithFrame)

    很多朋友如果是初学iOS开发,可能会被其中的几个加载方法给搞得晕头转向的,但是这几个方法又是作为iOS程序员必须要我们掌握的方法,下面我将对这几个方法做一下分析和对比,看看能不能增加大家对几个方法的理 ...

  4. 80人环游世界(bzoj 2055)

    Description     想必大家都看过成龙大哥的<80天环游世界>,里面的紧张刺激的打斗场面一定给你留下了深刻的印象.现在就有这么     一个80人的团伙,也想来一次环游世界. ...

  5. mariadb中执行数据库脚本的方法

    为了项目需求,写如下sql数据库脚本: SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for ...

  6. springboot 邮件

    <!-- 邮件end --><dependency> <groupId>org.springframework.boot</groupId> <a ...

  7. 倒计时器CountDownLatch与同步屏障CyclicBarrier

    CountDownLatch CountDownLatch是一个非常实用的多线程控制工具类,这个工具通常用来控制线程等待,它可以让某一个线程等待直到倒计时结束,再开始执行.在这里指CountDownL ...

  8. LeetCode OJ-- Pow(x, n) **@

    https://oj.leetcode.com/problems/powx-n/ 二分法 class Solution { public: double pow(double x, int n) { ...

  9. MVC 二级联动 可以试试

    后台代码,获取数据如下: /// <summary> 2 /// 获取省份 3 /// </summary> 4 public JsonResult GetProvinceli ...

  10. json手动解析详解

    项目中有时候仅仅需要一个或者多个字段时可以使用这种解析方式,省去创建实体类. 1.首先讲解下最基本的数据格式. 例如: String json="{'name':'小明','action': ...