其他分享
首页 > 其他分享> > c – 将Qt4移植到Qt5:未解析的外部符号

c – 将Qt4移植到Qt5:未解析的外部符号

作者:互联网

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

我有一个与Qt4建立良好的项目.我已经下载了Qt5-VisualStudio2010软件包,我正试图将我的项目从Qt4移植到Qt5.出现问题.

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

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

myproject.pro file:
QT += widgets

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

解决方法:

来自’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.

来自’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.

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

标签:c,linker,qt,qt5,porting
来源: https://codeday.me/bug/20190901/1782966.html