question about split compiling

Hi,

I used to like all-header style, I mean write the definition and implementation all in single .h file, I thought it's convenient.
But now I got a problem, my project grows larger and larger, there're lots of modules like net/login/send_msg..., the modules are all header-only, now a fully compile takes about 5 minutes. Once I modify a basic utility function that used by all other modules, such as build_packet(), there'll be a fully compile. Then I thought maybe I should split the build_packet() into .h and .cpp file, and compile the module into static library packet_builder.lib, then other modules are not affected and won't be recompiled.
question 1: This should save a lot of time, it that correct?

question 2: Must I split all files into .h and .cpp? Some third part file(downloaded from internet) have only .h, for example: charset.h that contains some function like AnsiToUtf8(), and this function is used by lots of modules, is it possible to compile these modules with the single .h file?

question 3: Any better way for accelerate the compiling speed when debugging?(No concern for release mode). I think even compile modules into static library is slow, when I build .exe, the compiler links all modules to exe, and it takes time. Would it be faster if I build modules to .dll?

questioin 4: The standard library(std) are also header-only files, why I feel the compilation very fast even when I include lots of std headers?

question 5: I'm using cmake to configure the project, any magic configuration that helpful?

Thanks.
Last edited on
If you're using CMake, it will handle all the annoying stuff for you and only recompile files that need to be recompiled.
Indeed, but it's still slow.l
Topic archived. No new replies allowed.