Building a multi module C project (i.e. solution) with Eclipse CDT

放肆的年华 提交于 2019-12-23 09:03:38

问题


I am moving from Netbeans to Eclipse (on Ubuntu 12.0.4). I have a C application that consists of several sub projects which are libraries (shared and static), as well as stand alone executables.

I can't figure out how to create a 'parent' project foo, which contains component projects

  • foobar
  • foofoo
  • barfoo
  • barbar

Ideally, I want all the 'component projects' to be created under the folder foo, so that I have a directory structure like this:

  • /path/to/foo/foobar/ (contains foobar project files)
  • /path/to/foo/foofoo/ (contains foofoo project files)
  • /path/to/foo/barfoo/ (contains barfoo project files)
  • /path/to/foo/barbar/ (contains barbar project files)

Does anyone know how I can achieve this structure using Eclipse as IDE (with CDT)?

Last but not the least, I intend to create my C modules using the Autotools option. Will the generated files for Autotools be automatically updated as I add new header/source to a module - or do I need to manually maintain the Autotool files?


回答1:


Friend, I think there is no the "parent" C project. You can create a normal C project in IDE and add all dependencies into sub-folders. Then tell compiler your build procedure via Makefile. I think it's easy way as you have had experience on C application.

About autotools, once you update/add/remove your project file, I think you need to modify your Makefile to reflect your change and do clean and rebuild your project.

For other C build tools, you can use buildroot if you'd like.




回答2:


The best way I can think to do this in eclipse is to create a separate workspace for the project e.g. foo, and then add the sub-projects (foobar, foofoo, etc...) as projects. This is generally a better approach to take with eclipse, instead of a single monolithic workspace. I don't know what the specific dependency structure for the sub-projects looks like, but you should be able to express it simply by using eclipse project properties. This can include a rollup executable sub-project that depends on the libraries.

Unfortunately, I'm not sure if eclipse cdt will maintain autotools files. However if not, it should be relatively easy to integrate and use some of the autotools binaries such as autoscan, and autoheader into the eclipse build commands.




回答3:


At first you need to a working directory, Then you should new project, Then per file or per class (according to C++ or C ) append your files, it's much safe way. another way is not clean, i have experience. don't use them.



来源:https://stackoverflow.com/questions/16599942/building-a-multi-module-c-project-i-e-solution-with-eclipse-cdt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!