I have a question related to C++ static library and dynamic library. Suppose now you are developing a program, and one functionality can be found in a C++ library. Then you have two choices: one is to write some codes (suppose not too many) and re-implement the function; the other is to invoke the function from the C++ library. However, the C++ library you want to use is a very big one while you only use a very small part of the library. In this case, what is a better choice? Thanks!
Share
static library linking will only link your executable with the symbols you effectively use.
say you have 200 functions in the lib and use only 4 (including inner calls of the lib), then only the 4 symbols you used will be linked in the executable. so linking with a 2Mb lib may result adding only 20k to your executable.
dynamic libraries under windows should be symbol complete , ie, the DLL will contain the 200 symbols wether you need only 4. while it won’t have a big impact on your executable size (since the lib used to link with the DLL is only a symbol forwarder) , it may impact load time & memory footprint.