E
E
Evgeny Nikitin2016-02-12 19:20:45
C++ / C#
Evgeny Nikitin, 2016-02-12 19:20:45

How to correctly assemble a dynamic library from static ones and is it worth it?

Situation: I have several components, they can be both in the form of source codes, and in the form of already compiled static libraries. As a result, I want to get one dynamic library with which I will already work. Now I am writing in Visual Studio, but I plan to abstract using CMake. In Visual Studio the solution looks something like this:
StaticLibProject1
StaticLibProject2
DynamicLibProject

Projects are linked via References - DynamicLibProject depends on both static libraries.
The desired result in the studio was achieved by changing the project settings for DynamicLibProject - Linker -> General -> Use Library Dependency Inputs: Yes. Questions - is it worth doing this, what are the consequences, how to repeat the same with CMake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2016-02-12
@eunikitin

CMake will just build the same solution you already have. Plus, it will be able to compile projects for other compilers. If you are not going to use other compilers, then there will be no fundamental benefit from CMake.
If the library is large and takes longer than a few minutes to build, then it makes sense to compile it into a dll, so that later programs using it do not waste time compiling. If there are few files, you can leave the source as well. The DLL is bound to the specific runtime version that was used when it was built. Plus debug/release versions. Plus, when updating the compiler, recompilation of libraries may be required.
A source library can be more efficiently optimized by the compiler and linker.
In the era of git and open source, it's considered good practice to provide source code and CMake for building projects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question