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

时间:2013-01-23 12:13:03

标签: c++ qt build qt-creator qt5

我在 Mac OS X 10.7上安装了 Qt 5.0.0 qt-mac-opensource-5.0.0-clang-offline.dmg )。 5 现在我正在尝试使用 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 添加的。

2 个答案:

答案 0 :(得分:11)

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

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

QT += widgets

答案 1 :(得分:1)

我遇到了同样的问题,说实话,我不知道如何设法让它解决。

我认为/猜测我将所需的文件夹从源文件复制到匹配的'clang_64'文件夹中,这样就完成了工作。

soo long zai

相关问题