简体   繁体   English

如何在Eclipse中组织C ++项目的依赖关系?

[英]How to organize dependencies for C++ project in Eclipse?

What's the recommended way to import dependencies for a C++ project in Eclipse? 在Eclipse中为C ++项目导入依赖项的推荐方法是什么?

For example, say I'm making a library and the project looks like 例如,假设我正在制作一个图书馆,项目看起来像

MyLib
- MyLib.cpp

Now I want to add the Lua library which I guess could just be under my project. 现在我想添加Lua库,我想它可能在我的项目下。 But the problem is it needs it's own build formula which it includes as a makefile 但是问题是它需要它自己的构建公式并将其作为makefile包含在内

MyLib
- MyLib.cpp
- Lua
-- lua.h
-- lua.c
-- Makefile
-- lua.a

Or I can import Lua into a new project and have my library reference it in several ways to find the header, the library and so on 或者,我可以将Lua导入到新项目中,并让我的库以几种方式引用它以查找标头,库等。

MyLib
- MyLib.cpp
Lua
- lua.h
- lua.c
- Makefile
- lua.a

The problem here is it takes a lot of fiddling with the build setups and after I get it right I'd like to be able to export everything someone needs to build my library so someone else can work on it. 这里的问题是,它需要花很多时间在构建设置上,而在我理解正确之后,我希望能够导出某人构建我的库所需的所有内容,以便其他人可以使用它。 (Or even just so I can work on it on another system.) (或者只是这样我就可以在另一个系统上工作了。)

I've seen a similar question about organizing Java projects and in that case they say to make a super project with other projects under it. 我已经看到过有关组织Java项目的类似问题,在这种情况下,他们说要与其他项目一起组成一个超级项目。 But this advice assumes you're using Maven and I think the answer may be different for a C++ project. 但是此建议假定您正在使用Maven,并且我认为答案对于C ++项目可能有所不同。 What is your advice? 你有什么建议?

I would suggest do external build system with for example make or even better cmake, and import project into Eclipse. 我建议使用make甚至更好的cmake进行外部构建,然后将项目导入Eclipse。 I usually works like that and that's fine solution. 我通常会那样工作,这是很好的解决方案。 You can clean/build your project by mouse from eclipse, debug and etc, but you just have to care about your build system by yourself. 您可以使用鼠标从Eclipse,Debug等中清理/构建项目,但您只需要自己关心构建系统。 Your code can compile without Eclipse, with standard tools, which is big advantage. 您的代码无需使用Eclipse即可使用标准工具进行编译,这是一大优势。

If you know better solution I will very glad to hear :-) 如果您知道更好的解决方案,我将非常高兴听到:-)

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

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