I used boost log in multiple project and just discovered a limitation in the way I should use/build the lib depending of the software component type static or shared I develop ode see here

The library has a separately compiled part which should be built as described in the Getting Started guide. One thing should be noted, though. If your application consists of more than one module (e.g. an exe and one or several dll's) that use Boost.Log, the library must be built as a shared object. If you have a single executable or a single module that works with Boost.Log, you may build the library as a static library.

Have an explanation/reason for that limitation ?

有帮助吗?

解决方案

This is because this library contains objects with internal linkage and static storage duration. Putting such objects into a shared library helps to make sure that there are no duplicates of such objects at run-time.

Note that static storage duration objects with external linkage do not suffer from this: if there is a duplicate definition at link time - the linker complains, at run-time - only the first available definition is used.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top