将Qt4移植到Qt5:未解析的外部符号 [英] Porting Qt4 to Qt5: unresolved external symbols

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

问题描述

Qt5是新一代的Qt,它有一些变化。



我有一个项目与Qt4建立良好。我已经下载Qt5-VisualStudio2010包,我试图将我的项目从Qt4到Qt5。出现问题。



所有include路径已修复。但是,编译器现在报告数百个未解析的外部符号(几乎所有的函数调用,听起来像编译器不能找到任何.lib文件)。我甚至试图添加在Qt SDK文件夹中找到的所有.lib文件,但没有用。最基本的类和方法:QApplication :: exec(...)也报告为未解析的符号。



项目文件已更改为适合Qt5包装:

  myproject.pro档案:
QT + = widgets
pre>

任何人都有类似的经验,这个新版本的Qt?

解决方案

从qt_newbie89( http://qt-project.org/forums/viewthread/23200 ):


我偶然解决了这个问题。我右键单击项目窗口中的
项目文件夹,然后选择qmake。之后,
选择运行,所有错误消失。我不知道为什么这样工作


从ChrisW67( http://qt-project.org/forums/viewthread/23253/ ):


Makefile文件没有变得损坏:它完全和你一样
留下它,充满了命令和路径适合于以前的Qt 4
安装。当Qt Creator运行nmake来构建项目nmake时,
不会自动重新运行qmake来生成Makefile,因为
(未修改)Makefile比生成它的pro文件更新。
这是正常和正确的make行为,但是它导致了你的Qt5中的Qt5和预期的Qt4安装之间的
不匹配。


我的说法:
是啊,真的解决了链接问题!问题实际上是,当项目是用Qt4创建时,'make'文件也与项目一起创建。当我删除Qt4,安装Qt5,并导入旧的项目通过Qt5(与新的Qt Creator),可能'make'文件已损坏。


Qt5 is the new generation of Qt and it has some changes.

I have a project building well with Qt4. I've downloaded Qt5-VisualStudio2010 package and I'm trying to port my project from Qt4 to Qt5. Problems arise.

All 'include' paths have been fixed well. However, the compiler now reports hundreds of 'unresolved external symbols' (almost all function calls, sounds like the compiler can't find any .lib file). I even tried to add all .lib files found in the Qt SDK folder, but useless. The most basic class and method: QApplication::exec(...) also reported as 'unresolved symbol'.

The project file has been changed to fit Qt5 packaging:

myproject.pro file:
QT += widgets

Anyone have got similar experience with this new release of Qt?

解决方案

From 'qt_newbie89' (http://qt-project.org/forums/viewthread/23200):

I have "accidentally" solved the problem. I rightclicked on the project folder in the Project windows and choose qmake. After that, choose Run and all the errors disappeared. I don’t know why that works by the way.

From 'ChrisW67' (http://qt-project.org/forums/viewthread/23253/):

The Makefile file did not "become corrupted": it was exactly as you left it, full of commands and paths suitable for the previous Qt 4 installation. When Qt Creator ran nmake to build the project nmake did not automatically re-run qmake to generate the Makefile because the (untouched) Makefile was newer than the pro file that generated it. This is normal and correct make behaviour, but it resulted in a mismatch between your Qt5 in stall and expected Qt4 install.

My saying: Yeah, that really solves the linking problem! The problem was actually that, when the project was created with Qt4, the 'make' file was also created along with the project nicely. When I removed Qt4, installed Qt5 and imported the old project by Qt5 (with new Qt Creator), possibly the 'make' file became corrupted.

这篇关于将Qt4移植到Qt5:未解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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