1

We have a application with various dynamic libs, which all use Boost 1.48 (static). Due to a third-party dependency on Boost Filesystem v2, we can't switch to a more recent Boost version for the application.

For a new functionality we develop a new dynamic lib for the application, which should also be used in some other projects. Can we use a recent (static?) Boost lib for this new lib, without interfering the Boost lib already used in the application?

Any traps I should avoid?

Simon
  • 1,616
  • 2
  • 17
  • 39
  • 1
    I don't see where's the problem, if you set different projects to use different versions of boost. – Jepessen Jul 03 '15 at 12:54
  • 1
    see also http://stackoverflow.com/questions/27312123/boost-libraries-built-with-relative-paths/27312154#27312154 – sehe Jul 03 '15 at 14:15

2 Answers2

3

Boost libraries generally do not support mixing different versions of libraries. Whether doing so would cause problems or not depends on many factors, among which are the libraries in question, your application design and the target platform. One source of problems can be symbol relocation which is part of the linking process on Linux and other UNIX-like systems. Even if you link with static libs of Boost, the linked symbols can still be exported from your binaries and may clash when you load your application. This can cause all sorts of undefined behavior and is often very difficult to debug.

In general, I would highly discourage from mixing different releases of Boost in the same application (i.e. a runtime process).

Andrey Semashev
  • 10,046
  • 1
  • 17
  • 27
  • Even with `-fvisibility=hidden` ? – Mariusz Jaskółka Apr 09 '20 at 06:56
  • @jaskmar Yes, because some Boost symbols are explicitly marked with default visibility. Even for components that have hidden visibility, if there is a place anywhere in the program where objects created by one Boost version are processed by another Boost version, you will probably have a problem. – Andrey Semashev Apr 09 '20 at 08:12
1

If you are using a static boost library to build your dynamic library, the static boost library will not create side effect with another boost static or dynamic library.

eroween
  • 163
  • 11