C++项目组织

发布于 2024-12-02 02:25:46 字数 526 浏览 4 评论 0原文

我已成为共享库项目的维护者。该库被分成几个模块,每个模块都编译为静态库,然后链接在一起。使用Eclipse作为IDE,代码存储在SVN服务器上。到目前为止,构建过程是手动处理的 - 构建库,将所有 .a 和 .h 移动到共享文件夹中,然后构建共享库。代码需要针对linux、ARM 和windows 进行编译。

问题是我需要更多地拆分当前模块,以便更好地测试(多个测试和示例简单程序,只有一个带有 main 的 .cpp 文件)和模块间代码共享(两者模块A和B使用C,但我不想连接A和B)。这会导致更复杂的依赖关系树,很难手动处理。我还需要能够构建一个项目的更多配置,可能链接到不同版本的依赖项目。

您将如何组织代码并设置开发环境?

编辑:我需要从DE的具体东西:

  1. 带有GUI的IDE(我喜欢vim和shell,但其他人不喜欢)
  2. 单独的项目,每个项目创建静态库,要包含的标头集和示例程序
  3. 每个项目的不同配置,链接/包括不同版本和/或依赖项配置
  4. 代码完成和 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:

  1. IDE with GUI (I like vim and shell, but the others don't)
  2. Separate projects, each creating static library, set of headers to include and example programs
  3. Different configurations for each project, linking/including different versions and/or configurations of dependencies
  4. Code completion and SVN support

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

二货你真萌 2024-12-09 02:25:46

make 和 Makefile 是用于此类构建和链接作业的成熟且经过深思熟虑的方法,特别是与 automakelibtool 结合使用。这些工具与 SVN 以及可能与 Eclipse 集成得很好。

make and Makefiles are the established and very well-thought-out method for such building and linking jobs, especially in combination with automake and libtool. These tools integrate excellently with SVN, and probably also with Eclipse.

只有影子陪我不离不弃 2024-12-09 02:25:46

所以我暂时解决了。我创建了一个名为 Pool 的文件夹。目录树:

Pool
 - inc
    - arm
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
    - lin
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
    - win
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
 -lib
    - arm
      - libproj1.a
      - libproj2.a
      - libproj3.a
    - lin
      - libproj1.a
      - libproj2.a
      - libproj3.a
    - win
      - libproj1.a
      - libproj2.a
      - libproj3.a

使用 makefile 自动将库复制到此处。包括标题:

#include "proj1/someheader.h"

链接它:

-L${POOL}/lib/arm -lproj1

注意:注意 -l <​​em>library 参数顺序。

So I solved it for now. I created a folder called Pool. Directory tree:

Pool
 - inc
    - arm
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
    - lin
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
    - win
      - proj1 public headers directory
      - proj2 public headers directory
      - proj3 public headers directory
 -lib
    - arm
      - libproj1.a
      - libproj2.a
      - libproj3.a
    - lin
      - libproj1.a
      - libproj2.a
      - libproj3.a
    - win
      - libproj1.a
      - libproj2.a
      - libproj3.a

The libraries are copied here automatically using makefile. Including header:

#include "proj1/someheader.h"

Linking it:

-L${POOL}/lib/arm -lproj1

Note: beware of -l library parameters order.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文