C++项目组织
我已成为共享库项目的维护者。该库被分成几个模块,每个模块都编译为静态库,然后链接在一起。使用Eclipse作为IDE,代码存储在SVN服务器上。到目前为止,构建过程是手动处理的 - 构建库,将所有 .a 和 .h 移动到共享文件夹中,然后构建共享库。代码需要针对linux、ARM 和windows 进行编译。
问题是我需要更多地拆分当前模块,以便更好地测试(多个测试和示例简单程序,只有一个带有 main
的 .cpp 文件)和模块间代码共享(两者模块A和B使用C,但我不想连接A和B)。这会导致更复杂的依赖关系树,很难手动处理。我还需要能够构建一个项目的更多配置,可能链接到不同版本的依赖项目。
您将如何组织代码并设置开发环境?
编辑:我需要从DE的具体东西:
- 带有GUI的IDE(我喜欢vim和shell,但其他人不喜欢)
- 单独的项目,每个项目创建静态库,要包含的标头集和示例程序
- 每个项目的不同配置,链接/包括不同版本和/或依赖项配置
- 代码完成和 SVN 支持
I've become a maintainer of a shared library project. The library is split into a few modules, each of them compiled as static library, then linked together. Eclipse is used as IDE, code stored at SVN server. So far the building process was handlet by hand - building libraries, moving all the .a and .h into shared folder, then building the shared library. The code needs to be compiled for linux, ARM and windows.
The problem is that I need to split the current modules a little bit more, for better testing (multiple test and example simple programs, just one .cpp file with main
) and inter-module code sharing (both module A and B use C, but I don't want to connect A and B). This results into more complex dependency tree which is going to be difficult to handle by hand. I also need to be able to build more configurations of one project, possibly linking to different version of dependent projects.
How would you organise the code and set up the development environment?
EDIT: the concrete things I need from the DE:
- IDE with GUI (I like vim and shell, but the others don't)
- Separate projects, each creating static library, set of headers to include and example programs
- Different configurations for each project, linking/including different versions and/or configurations of dependencies
- Code completion and SVN support
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
make
和 Makefile 是用于此类构建和链接作业的成熟且经过深思熟虑的方法,特别是与automake
和libtool
结合使用。这些工具与 SVN 以及可能与 Eclipse 集成得很好。make
and Makefiles are the established and very well-thought-out method for such building and linking jobs, especially in combination withautomake
andlibtool
. These tools integrate excellently with SVN, and probably also with Eclipse.所以我暂时解决了。我创建了一个名为 Pool 的文件夹。目录树:
使用 makefile 自动将库复制到此处。包括标题:
链接它:
注意:注意 -l <em>library 参数顺序。
So I solved it for now. I created a folder called Pool. Directory tree:
The libraries are copied here automatically using makefile. Including header:
Linking it:
Note: beware of -l library parameters order.