【问题标题】:During compilation QMainWindow is unable to be found在编译期间无法找到 QMainWindow
【发布时间】:2013-10-04 10:41:45
【问题描述】:

我正在尝试编译cutetcash(一个qt项目)并且遇到了一些麻烦。我只是在做标准:

cmake .
make

但是,我收到有关无法找到 QMainWindow 和 QString 等错误。这是错误:

http://pastebin.com/GGHTXE4N

In file included from /home/username/code/gnucash/src/gnc/fpo/ViewletView.hpp:14:0,
                 from /home/username/code/gnucash/src/gnc/fpo/FPO.hpp:4,
                 from /home/username/code/gnucash/src/gnc/fpo/moc_FPO.cxx:9:
/home/username/code/gnucash/src/gnc/mainwindow.hpp:26:23: fatal error: QMainWindow: No such file or directory
compilation terminated.
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:15:2: error: #error "This file was generated using the moc from 5.0.1. It"
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:16:2: error: #error "cannot be used with the include files from this version of Qt."
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:17:2: error: #error "(The moc has changed too much.)"
In file included from /home/username/code/gnucash/src/gnc/AccountItemModel.hpp:28:0,
                 from /home/username/code/gnucash/src/gnc/dashboard.hpp:34,
                 from /home/username/code/gnucash/src/gnc/moc_dashboard.cxx:9:
/home/username/code/gnucash/src/gnc/QofEventWrapper.hpp:37:19: fatal error: QString: No such file or directory
compilation terminated.
In file included from /home/username/code/gnucash/src/gnc/SplitListModel.hpp:29:0,
                 from /home/username/code/gnucash/src/gnc/moc_SplitListModel.cxx:9:
/home/username/code/gnucash/src/gnc/QofEventWrapper.hpp:37:19: fatal error: QString: No such file or directory
compilation terminated.

似乎相当重要的事情:

error: #error "This file was generated using the moc from 5.0.1. It"
error: #error "cannot be used with the include files from this version of Qt."
error: #error "(The moc has changed too much.)"

所以每当我尝试安装 qt5-default(在 ubuntu 上)时,我必须删除 qt4-default。如果我现在尝试编译,我会遇到同样的问题,无法找到 QMainWindow 和其他一些部分(例如 QAbstractItemDelegate)。

我也收到此警告:

#error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC or -fPIE."

还有一些似乎是由于无法找到项目而发生的新错误。我在 ubuntu 13.04 上。

【问题讨论】:

  • 我猜 QMainWindow 类在 Qt5 中被移到了 QtWidgets 模块。
  • 真的。尝试将 +widgets 添加到 .pro 文件或尝试使用 Qt4.8
  • 实际上没有 .pro 存在,一切都设置为通过 cmake 工作。我正在使用 4.8.4
  • 我会清除您的 cmake 缓存并重新配置和重新生成,以确保 cmake 找到 Qt-4.8.4 而不是 Qt5。
  • 他们太失败了... -- package 'guile-1.8>=1.8.0' not found CMakeLists.txt:89 (MESSAGE) 处的 CMake 错误:未找到 Guile,但必需的。请设置 PKG_CONFIG_PATH 以便找到 guile-1.8.pc。我们在 Archlinux 上有 2.0,所以...

标签: c++ qt ubuntu qt4 cmake


【解决方案1】:

适合我的步骤:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-25
    • 1970-01-01
    • 2012-12-19
    • 2012-10-21
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多