Creating a Dynamic Library/Framework

Good Evening,

Recently while using SQLite I noticed that they supplied an amalgamation of their entire source code in just two files. By doing so they gained performance enhancements due to the way that the compiler optimized the code during compilation.

Would this strategy work on other libraries/frameworks or is this something that depends on the specific project. Obviously source code would be harder to maintain in a single file but that aside - are there any additional benefits/drawbacks I should consider?

Many thanks and kind regards,

Phil.
You only need to do this with compilers and linkers that do not provide whole program and link time optimization. Newer GCC, for example, provides both.

http://gcc.gnu.org/wiki/LinkTimeOptimization

The downsides of a single file are maintainability and compilation cost. How frequently do you need *everything* in that header? That said, SQLite isn't the only one to do that. OTL does the same thing: everything exists in just one header.

Just put everything into a bunch of header files, and put everything that cannot exist in a header into source files (usually just static constants). You'll get the same effect without a single monolithic header.
Topic archived. No new replies allowed.