1

Xcode 5.0.1,Mac OS 10.9,尝试使用 Qt-Creator 3.0 beta。

我需要将 Qt 5.2 与 32 位第三方库一起使用,所以我希望 Qt 和我的应用程序是 32 位的。是的,我知道现在是 2013 年……但我现在别无选择。

我用以下内容构建了 Qt 5.2 (beta),做了“make”和“make install”。一切都好。

./configure -debug-and-release -commercial -confirm-license -nomake examples -platform macx-clang-32 -arch x86 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql  -no-sql-symbian -no-sql-symsql -no-sql-tds  -prefix ~/dev/qt5

现在我想通过构建一个简单的“Hello World”应用程序来测试 Qt 5.2。但即使我的 Qt 是为 32 位构建的,即使设置了 Qt 版本和工具包,并且我使用“Clang(/usr/bin 中的 x86 32 位)作为我的编译器,我也会遇到链接错误,就好像我的“hello world”应用程序正在为 x86_64 构建。

首先我收到警告:

"...QtGui.framework/QtGui, file was built for i386 which is not the architecture being linked (x86_64)...   QtWidgets.framework/QtWidgets, file was built for i386 which is not the architecture being linked (x86_64)...... etc"

然后我自己得到错误:

Undefined symbols for architecture x86_64:
  "qt_assert(char const*, char const*, int)", referenced from:
      QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::operator->() const in moc_mainwindow.o
  "QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)", referenced from:
      QTypedArrayData<unsigned short>::deallocate(QArrayData*) in mainwindow.o
  "QStatusBar::QStatusBar(QWidget*)", referenced from:
      Ui_MainWindow::setupUi(QMainWindow*) in mainwindow.o
  "QMainWindow::addToolBar(QToolBar*)", referenced from: ..... etc

我尝试将其添加到我的 *.Pro 文件中:

CONFIG += qt x86
CONFIG -= x86_64

但它仍然尝试构建 X86_64。

如何强制我的 hello-world 应用程序构建 32 位并与我构建的 32 位 Qt 框架兼容?

谢谢。

4

1 回答 1

2

看来,对于同一个“hello world”.pro 文件,我可以从命令行执行此操作:

~/dev/qt5/bin/qmake -spec macx-clang-32 test2.pro
make

它将使用 32 位 (i386) 正确构建所有内容。它将与我构建的 i386 Qt 5.2 正确链接。

然而:

将相同的 .pro 文件加载到 Qt-Creator 3 beta 中:并构建——它将尝试构建它 x86_64 并且当然在链接上失败。

您可以在命令行中看到差异:当我从命令行执行此操作时添加了“-arch i386”,但当我从 QtCreator 3.0 beta 执行此操作时未添加。

查看确切的根本原因:我可以看到,当我使用命令行时,规范是“macx-clang-32”。当我在 QtCreator 3.0 beta 中使用它时,规范是“macx-clang”。

所以解决方法是:

我在项目构建设置中强制它回到 macx-clang-32,现在我可以在 QtCreator 3.0 中构建 32

于 2013-10-31T15:24:58.620 回答