简体   繁体   English

eclipse CDT:重建一个依赖项目

[英]eclipse CDT: rebuilding a dependent project

I'm working on a C++ project with eclipse Indigo + CDT running on linux 我正在研究一个在Linux上运行eclipse Indigo + CDT的C ++项目

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! 这非常令人讨厌,因为我在使用库时经常有工作版本,然后在某些时候我进行完全重建,我看到了大量错误,我在30分钟前做过的事情!

example output of the CDT Global Build Console: 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 ****

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. 如果您已经习惯了最新版本的MS Visual Studio,那么您应该清理桌面上的空间并用巨大的“X”标记它 - 这很可能是你的拳头,甚至是你的脑袋在使用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. Eclipse有它自己的依赖机制几乎什么也没做,但幸运的是CDT模块有自己的依赖机制,它试图做你想要的。 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. 因此,在您的示例中,您将转到“libxxx_tests”的项目属性,并选择“libxxx.a”作为依赖项。

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. 请注意,您还可以使用此页面设置库顺序,这可能是一个重要的步骤,具体取决于项目的复杂程度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM