5

我在Mac OS X 10.7.5上安装了Qt 5.0.0 ( qt-mac-opensource-5.0.0-clang-offline.dmg ) ,现在我正在尝试使用Qt Creator 2.6编译“ Hello World ”应用程序。 1 .

构建过程抱怨找不到目录:/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添加的。

4

2 回答 2

12

事实证明,无效qtbase路径实际上是最初在QTBUG-28336报告的 Qt 错误。

链接问题是由于我的项目没有与 QtWidgets 链接,这是我们从 Qt5 开始必须要做的事情。这是通过将以下行添加到您的.pro文件中来完成的:

QT += widgets
于 2013-01-23T12:13:02.860 回答
1

我有同样的问题,老实说,我不知道我是如何解决的。

我想/猜想我将所需的文件夹从源文件复制到匹配的“clang_64”文件夹中,这样就可以了。

苏龙仔

于 2013-01-23T13:32:16.603 回答