【问题标题】:Qt4.8 + CMake 2.8.5 on OSX 10.5.8 can't linkOSX 10.5.8 上的 Qt4.8 + CMake 2.8.5 无法链接
【发布时间】:2012-03-29 07:50:33
【问题描述】:

我在OSX Leopard 上使用Qt4.8 而不是qmake+QtCreator 我想在OSX 上使用CMake 编译一个非常简单的project 以了解如何做一个包。

虽然同一个项目在 Linux 下可以顺利编译和链接,但在我的 OSX 机器下,这是我在链接阶段总是收到的错误消息:

ld warning: in /Library/Frameworks//QtGui.framework/QtGui, file is not of required architecture
ld warning: in /Library/Frameworks//QtCore.framework/QtCore, file is not of required architecture
Undefined symbols:
  "QWidget::mousePressEvent(QMouseEvent*)", referenced from:
      vtable for TestFormin moc_TestForm.cxx.o
  "QObject::childEvent(QChildEvent*)", referenced from:
      vtable for TestFormin moc_TestForm.cxx.o
  "QWidget::actionEvent(QActionEvent*)", referenced from:
      vtable for TestFormin moc_TestForm.cxx.o
  "QCoreApplication::translate(char const*, char const*, char const*, QCoreApplication::Encoding)", referenced from:

等等等等。

我想用 cmake 编译的每个项目都会发生这种情况。 知道发生了什么吗?

【问题讨论】:

    标签: macos qt linker cmake osx-leopard


    【解决方案1】:

    检查cmake (CMAKE_OSX_ARCHITECTURES) 正在使用什么架构 (i386,x86_64)。尝试向cmake推荐架构:

    cmake -DCMAKE_OSX_ARCHITECTURES=x86_64
    

    【讨论】:

    • 谢谢,这解决了我的问题!我必须只保留 x86_64 架构,因为我的 Qt 库仅在该架构中提供。
    猜你喜欢
    • 2013-04-29
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    相关资源
    最近更新 更多