开发者

C++ project organisation

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 开发者_如何学Cshared 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


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜