简体   繁体   English

构建简单的Qt5应用程序时出错

[英]Error building simple Qt5 application

I installed Qt 5.0.0 ( qt-mac-opensource-5.0.0-clang-offline.dmg ) on a Mac OS X 10.7.5 and now I'm trying to compile a " Hello World " application using Qt Creator 2.6.1 . 我在Mac OS X 10.7.5上安装了Qt 5.0.0qt-mac-opensource-5.0.0-clang-offline.dmg ),现在我正在尝试使用Qt Creator 2.6编译“ Hello World ”应用程序。 1

The build process complains about a directory not found: /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib , followed by several linking errors: 构建过程抱怨找不到目录: /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

It's important to note that the path /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib is not valid because the directory qtbase doesn't exist. 重要的是要注意路径/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib无效,因为目录qtbase不存在。 The working path is /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib . 工作路径是/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib I'm not referring to qtbase anywhere in my project, so this is probably being added by qmake . 我在项目的任何地方都没有提到qtbase ,所以这可能是由qmake添加的。

As it turns out, the invalid qtbase path thing is really a Qt bug originally reported at QTBUG-28336 . 事实证明, 无效的qtbase路径事实上是 QTBUG-28336最初报告的Qt bug

The linking problem is due to my project not linking with QtWidgets , which is something we are going to have to do starting in Qt5. 链接问题是由于我的项目没有与QtWidgets链接 ,这是我们在Qt5开始要做的事情。 This is accomplished by adding the following line to your .pro file: 这是通过在.pro文件中添加以下行来完成的:

QT += widgets

i had the same problem and to be honest im not shure how i managed it to solve. 我有同样的问题,说实话我不是不知道我是如何设法解决的。

i think/guess i copied the needed folders from the sources into the matching 'clang_64' folders and that does the job. 我认为/猜测我将所需的文件夹从源文件复制到匹配的'clang_64'文件夹中并完成工作。

soo long zai soo long zai

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM