This topic is now archived and is closed to further replies.


split a project into several libraries?

Recommended Posts

is it a good or bad idea to split the code into several different static libraries (projects in vc++ 6 ) lets say I''m working on a 3D engine, and then I write different parts into different libraries which I later put together into one engine.. or would it be better to write everything into the same project I could split the parts like this EngineCore - the main part where all stuff and general stuff is Kernel - the task manager ( like the one in Enginuity ) RenderSystem - rendering queue and all that needs to draw geometry on screen, maybe using plugins for different API''s SceneGraph - The scene graph thing that sorts the different objects into a BSP tree or something, for culling Math3D - The 3D basics, cVerte3f, cMatrix4x4 etc. ( I wrote this so I can keep it if I want to rewrite all other stuff ) every little library above is linked to the EngineCore.dll file that will be used for the graphics-project later on, and a plugin-dll for the Render-api stuff. I have noticed that the OGRE has put all stuff into one project/lib (except plugins). is this only a mather of choice of the programmer or something?

Share this post

Link to post
Share on other sites
If it''s only for your own use, then you won''t see much benefit from this. But it may make it easier for you to use in other projects later.

Ogre has everything combined partly because it uses a lot of C++ templates, I think. Templates are resolved at compile time rather than link time so there''s only so far you can go with isolating it into separate libraries.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post

Link to post
Share on other sites
For me it makes a huge difference putting everything in libraries. I reuse code all the time and the alternative is to maintain multiple copies of the same code in multiple places. That would be a nightmare. Here is a quick list of the libraries I reuse the most:


On the other hand, I would probably not put most of the components you mentioned in separate libraries. You are not likely to reuse them separately and you will be giving up some flexibility by putting them in separate libraries.

Share this post

Link to post
Share on other sites
I want to write my libraries good so I can reuse them to other projects, just becouse I don''t need to rewrite that part and then I tend to write better code to becouse I want it to be good so I can use it for several projects

I began with the splitting into libraries when I found it a bit easier to keep some controll of my code and that I could use one library in several projects without copy the source for that library into several projects.
for example I made a nice logging system and I copy all the source files all over the place there was different versions of that loggingsystem in every different project I hade written.. so then I wrote a new LogSystem.lib that I can include to my projects when I need to use some logging thing.

but what is a good rule when I should create a new library? is there anything I should think of?

Share this post

Link to post
Share on other sites