开发者

eclipse CDT: rebuilding a dependent project

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 p开发者_运维知识库roject. 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 ****


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜