eclipse CDT:重建依赖项目

发布于 2024-11-26 06:41:57 字数 1184 浏览 1 评论 0原文

我正在开发一个在 linux 上运行的 eclipse Indigo + CDT 的 C++ 项目

,它由一个库项目和一个包含该库单元测试的项目组成。
显然,第二个项目取决于第一个项目。
两个项目都使用外部构建器

但是当我修改第一个项目的标头时,它不会重建测试项目。我无法让它做到这一点...它只会重新链接第二个项目,即使标头包含在测试项目中。这非常烦人,因为我经常在处理库时进行工作构建,然后在某个时候我进行完全重建,然后在我 30 分钟前所做的事情上看到大量错误!

CDT 全局构建控制台的示例输出:

**** Build of configuration Debug for project libxxx ****

make -j all 
Building file: ../foo.cpp
Invoking: GCC C++ Compiler
ccache g++ -I"/home/foke/workspaces/cpp/libxxx/include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"foo.d" -MT"foo.d" -o "foo.o" "../foo.cpp"
Finished building: ../foo.cpp

Building target: libxxx.a
Invoking: GCC Archiver
ar -r  "libxxx.a"  ./foo.o  ./src/yyy.o  ./src/detail/zzz.o   
ar: creating libxxx.a
Finished building target: libxxx.a


**** Build Finished ****

**** Build of configuration Debug for project libxxx_tests ****

make -k -j all 
Building target: libxxx_tests
Invoking: Cross G++ Linker
g++ -L"/home/foke/workspaces/cpp/libxxx/Debug" -o "libxxx_tests"  ./main.o ./aaa.o  ./tests/bbb.o ./tests/ccc.o ./tests/ddd.o   -lboost_unit_test_framework -lxxx
Finished building target: libxxx_tests


**** Build Finished ****

I'm working on a C++ project with eclipse Indigo + CDT running on linux

It's made of a project for a library, and a project with unit tests for this library.
Obviously the second project depends on the first one.
Both projects use the external builder

But when I modify a header of the first project it does not rebuild the test project. And I can't make it do it... It'll just re-link the second project, even though the header is included in the test project. This is very annoying because I often have working builds while working on the library, then at some point I do a full rebuild and I see a load of errors, on stuff I did 30 minutes ago!

example output of the CDT Global Build Console:

**** Build of configuration Debug for project libxxx ****

make -j all 
Building file: ../foo.cpp
Invoking: GCC C++ Compiler
ccache g++ -I"/home/foke/workspaces/cpp/libxxx/include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"foo.d" -MT"foo.d" -o "foo.o" "../foo.cpp"
Finished building: ../foo.cpp

Building target: libxxx.a
Invoking: GCC Archiver
ar -r  "libxxx.a"  ./foo.o  ./src/yyy.o  ./src/detail/zzz.o   
ar: creating libxxx.a
Finished building target: libxxx.a


**** Build Finished ****

**** Build of configuration Debug for project libxxx_tests ****

make -k -j all 
Building target: libxxx_tests
Invoking: Cross G++ Linker
g++ -L"/home/foke/workspaces/cpp/libxxx/Debug" -o "libxxx_tests"  ./main.o ./aaa.o  ./tests/bbb.o ./tests/ccc.o ./tests/ddd.o   -lboost_unit_test_framework -lxxx
Finished building target: libxxx_tests


**** Build Finished ****

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

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

发布评论

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

评论(1

久而酒知 2024-12-03 06:41:57

如果您习惯了最新版本的 MS Visual Studio,那么您应该在桌面上清理出一个空间,并用一个巨大的“X”标记它 - 这在使用 Eclipse 时不可避免地会让您的拳头甚至您的头感到沮丧。 /CDT。

Eclipse 有它自己的依赖机制,几乎什么都不做,但幸运的是 CDT 模块有它自己的依赖机制,它试图做你想做的事情。要设置项目依赖项,请转到:

Project-->Properties-->C/C++ General-->Paths and Symbols-->References

因此,在您的示例中,您将转到“libxxx_tests”的项目属性并选择“libxxx.a”作为依赖项。

请注意,您还可以使用此页面来设置库顺序,这可能是一个重要的步骤,具体取决于项目的复杂性。

If you're used to the latest versions of MS Visual Studio then you should clear off a space on your desk and mark it with a giant 'X' - this enevitably where your fist and maybe even your head will bang in frustration when using eclipse/CDT.

Eclipse has it's own dependency mechanism which does almost nothing, but fortunately the CDT module has its own dependency mechanism which tries to do what you want. To set up project dependencies go to:

Project-->Properties-->C/C++ General-->Paths and Symbols-->References

So in your example you would go to the project properties for "libxxx_tests" and select "libxxx.a" as a dependency.

Note that you can also use this page to set the library order, which may be an important step depending on the complexity of your project.

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