Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared library and client application both using shared libglog.so #244

Closed
davidalbertonogueira opened this issue Sep 19, 2017 · 1 comment

Comments

@davidalbertonogueira
Copy link

How should someone approach these situations, in which a dynamic library uses Glog, and my client application also uses Glog? They cannot both call InitGoogleLogging because that leads to a program crash.
But the dynamic library cannot drop that Logging initialization call because it can be used in applications without Glog. Shouldn't exist something like InitGoogleSharedLogging?
Moreover, how to approach cases when the shared library and the main client use different versions of a library or one of them has Glog coupled with Gflags and the other not? How to make each one point to its "rightful" library?

@sergiud
Copy link
Collaborator

sergiud commented Jan 5, 2018

AFAIK, dynamic libraries should not call any (third party) initialization routines. Instead, this should be application's responsibility (in the main). Only this way the order of initialization routines can be specified. By following this rule, most of the problems can be avoided.

As for the second question: why can't you make sure that exactly one version of the library is used? For instance, creating a superbuild using CMake's ExternalProject module can ensure that only a specific version of the library is shared among several projects. This eventually allows to avoid related deployment issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants