Eclipse CDT/Qt:有一个 Qt Gui 项目依赖于另一个 C++工作区中的项目

发布于 2024-10-31 04:50:00 字数 819 浏览 1 评论 0原文

我使用 Eclipse/CDT 在 Eclipse C++ 项目(“MyAlgorithm”)中实现了一个相当复杂的算法。为了能够可视化算法的步骤,我想创建一个简单的 Qt GUI。我已经下载并安装了 Qt Eclipse 集成,并创建了一个带有主窗口的 Qt 项目(“MyGUI”)。一切都按照应有的方式进行编译 - 各个组件都已就位。

然而,当我尝试在 MyGUI 中使用 MyAlgorithm 中的类时,一切都停止了...尽管我在我能想到的所有可能的对话框和位置中引用了 MyGUI 中的 MyAlgorithm [1],但构建项目仍然失败:

main.cpp:5: 致命错误: MyAlgorithmClass.h: 没有这样的文件或目录

我在 MyGUI 中引用 MyAlgorithm 的位置列表(全部在“MyGUI”的项目属性中):

  • C/C++ 包含路径和符号(使用“从工作空间添加包含路径...”)
  • C/C++ 项目路径(选项卡“项目”,检查列表“构建路径上所需的项目”
  • 项目引用中的“MyAlgorithm”项目,检查列表“‘MyGUI’的项目引用”中的“MyAlgorithm”项目

虽然构建过程失败,但当我尝试包含时,Eclipse/CDT 自动完成功能确实表明存在“MyAlgorithmClass.h”我还注意到,更改项目设置(如上面的列表中所述)不会触发 Makefile 中的任何更改,

这可能是 Qt Eclipse 集成阻止 CDT 更新的情况。相应的 Makefile,由于编译器/链接器缺少参数而导致构建过程失败?

感谢您的帮助!

I've implemented a rather complex algorithm in an Eclipse C++ project ("MyAlgorithm") using Eclipse/CDT. In order to be able to visualise the steps of the algorithm, I'd like to create a simple Qt GUI. I've downloaded and installed the Qt Eclipse integration and have created a Qt Project ("MyGUI") with a main window. Everything compiles like it should - the individual components are all in place.

However, when I try to use the classes from MyAlgorithm in MyGUI, everything grinds to a stop... Although I've referenced MyAlgorithm in MyGUI in all possible dialogs and places I can think of [1], building the project still fails with:

main.cpp:5: fatal error: MyAlgorithmClass.h: No such file or directory

List of places where I've referenced MyAlgorithm in MyGUI (all in the project properties of "MyGUI"):

  • C/C++ Include Paths and Symbols (using "Add Include Path from Workspace...")
  • C/C++ Project Paths (tab "Projects", checked the "MyAlgorithm" project in list "Required projects on the build path"
  • Project References, checked the "MyAlgorithm" project in list "Project references for 'MyGUI'"

Although the build process fails, the Eclipse/CDT auto-complete feature does suggest the existence of "MyAlgorithmClass.h" when I try to include it in the "MyGUI" project. I also noticed that changing the project settings (as described in the list above) does not trigger any changes in the Makefile.

Might it be the case that the Qt Eclipse integration prevents CDT from updating the Makefile accordingly, causing the build process to fail because of missing parameters to the compiler/linker?

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2024-11-07 04:50:00

简而言之,QT-Eclipse 集成无法正常工作。您需要手动更新项目的 QT .pro 文件:

添加库:

使用语法添加任何库:

LIBS += -L<Full path to library include directory>
LIBS += -l<Eclipse Artifact>

example:

LIBS += -LC:/MyEclipseWorkspace/Project1/Debug
LIBS += -lProject1

这会将 libProject1.a 链接到您的 eclipse 项目中。

添加包含文件:

INCLUDEPATH += <Absolute or Relative Path to include location>

示例:

INCLUDEPATH += src ../Project2/include C:/dev/boost_1_46_1

HTH

The short answer is that the QT-Eclipse integration does not work correctly. You need to manually update the QT .pro file for your project:

Adding Libraries:

Add any libs using syntax:

LIBS += -L<Full path to library include directory>
LIBS += -l<Eclipse Artifact>

example:

LIBS += -LC:/MyEclipseWorkspace/Project1/Debug
LIBS += -lProject1

This will link libProject1.a into your eclipse project.

Adding Include Files:

INCLUDEPATH += <Absolute or Relative Path to include location>

example:

INCLUDEPATH += src ../Project2/include C:/dev/boost_1_46_1

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文