c++ - 移植Qt4到Qt5 : unresolved external symbols

标签 c++ qt linker porting 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++ - 移植Qt4到Qt5 : unresolved external symbols,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14107660/

相关文章:

c++ - clang vs gcc 模板子类在父类中使用前向声明的类

c++ - 从 vector C++ 中获取方矩阵的行数和列数

c++ - Qt Creator DEFAULT 项目模板和编译标志

c++ - 将它们传递给 cpp 后如何与 qml 项目值进行交互?

C++文件输出奇怪的数字,部分代码没有运行

c++ - std::thread 并在 visual studio 2013 中 move

c++ - 使用 QT creator 在树莓派上通过 Wifi 执行简单的终端命令

c# - 将 DLL 嵌入已编译的可执行文件中

c++ - 如何了解 C++ 链接/依赖项?

c++ - 在 Xcode 3 中链接库