构建简单的 Qt5 应用程序时出错
Error building simple Qt5 application
我在Mac OS X 10.7.5上安装了Qt 5.0.0(qt-mac-opensource-5.0.0-clang-offline.dmg),现在我正在尝试使用Qt Creator 2.6.1编译"Hello World"应用程序。
构建过程抱怨找不到目录:/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib
,后跟几个链接错误:
clang++ -c -pipe -mmacosx-version-min=10.6 -O2 -Wall -W -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/mkspecs/macx-clang -I. -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include/QtGui -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include/QtCore -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -o main.o main.cpp
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o hello_qt.app/Contents/MacOS/hello_qt main.o -F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib -framework QtGui -F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib -framework QtCore -framework OpenGL -framework AGL
ld: warning: directory not found for option '-F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib'
Undefined symbols for architecture x86_64:
"QApplication::QApplication(int&, char**, int)", referenced from:
_main in main.o
"QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)", referenced from:
_main in main.o
"QWidget::show()", referenced from:
_main in main.o
"QPushButton::QPushButton(QString const&, QWidget*)", referenced from:
_main in main.o
"QApplication::exec()", referenced from:
_main in main.o
"QPushButton::~QPushButton()", referenced from:
_main in main.o
"QLabel::~QLabel()", referenced from:
_main in main.o
"QApplication::~QApplication()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hello_qt.app/Contents/MacOS/hello_qt] Error 1
请务必注意,路径/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib
无效,因为目录 qtbase 不存在。工作路径是/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib
.我不是指我项目中任何地方的qtbase
,所以这可能是由 qmake 添加的。
事实证明,无效的qtbase
路径实际上是一个最初在QTBUG-28336上报告的Qt错误。
链接问题是由于我的项目没有与QtWidgets链接,这是我们从Qt5开始必须做的事情。这是通过将以下行添加到 .pro 文件来实现的:
QT += widgets
我遇到了同样的问题,老实说,我并不知道如何解决它。
我想/猜猜我将所需的文件夹从源复制到匹配的"clang_64"文件夹中,这完成了这项工作。
这么龙仔
相关文章:
- 使用 Visual Studio 2019 构建 Hello World wxwidgets 应用程序时出错
- 在发布模式下启动使用库的静态链接编译的应用程序时出错
- 从 ParaView 构建自定义 Qt 应用程序示例时出错
- 将 Dr. Memory 与 Visual Studio 项目配合使用时出错:缺少应用程序所需的库
- 尝试使用共享库部署QT应用程序时出错
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- std::stoul 在带有 NDK r13b 的 Android 版 Qt 应用程序上出错
- 编译向导生成的MFC应用程序时出错;缺少CDocument声明
- 尝试在Qt中运行应用程序时出错
- 编译C 应用程序(Apache Thrift)时出错
- 尝试使用 boost::interprocess::managed_shared_memory::构造<T>编译应用程序时出错
- 在另一个线程正在运行的情况下退出应用程序时出错
- 使用Visual Studio构建Freetype应用程序时出错
- 获取应用程序的内存使用情况时出错
- CMake:运行链接命令时出错:%1不是有效的Win32应用程序
- 使用 Unity 在 iOS 应用程序上发送电子邮件时出错
- 在Visual Studio中构建示例opencv应用程序时出错
- 在树莓树莓的交叉编译 qt 中构建应用程序时出错
- 构建应用程序时出错:体系结构 armv7 的未定义符号
- <QNetworkAccessManager><QNetworkReply> 在 BB10 应用程序开发的 cpp 文件中包含 时出错