This may be a silly question, but here it goes.
I have a library (call it
myLib) that depends on
yaml as well as another third-party library,
libA, which internally builds a version of
Dependency looks like:
|-- yaml version x
+-- yaml version y
I’m getting duplicate
yaml symbols when linking
myLib into an executable.
Is there any way to avoid this, other than forcing
myLib to adopt
yaml version y?
A few other pieces of information:
myLib is built in CMake, so is
libA is built in scons.
Every symbol with exernal linkage needs to be unique. You cannot have two different versions of a function with the same name in one executable.
This would only work with header only libraries that do not create any such symbol.
But it should work If you create
libA as shared library instead.
The other question is if you really want to have two different versions that potentially behave differently in the same executable.
This is a big reason why bundling is bad .
libA could alternatively mangle all of the
libyaml symbols in its internal copy to avoid such things, but this is so rare and means that
FetchContent doesn’t generally work (since the project needs patched), so it’s “never” done. If you do port it all to
FetchContent, there is some mechanism to at least get all of them agreeing to use the same
libyaml. Though you still have the issue if someone wants to consume
myLib with their own
libyaml (which may come in through
otherLib) as well…