I am working on a complex C ecosystem where different packages/libraries are developed by different people.
I would like to create a new project named foobar. This project uses two libraries, the library foo and the library bar.
Unfortunately, bar does not require the same version that foo requires. Both use say so there is a conflict.
If all the packages are on Git with submodules, the foobar project cannot be built when cloned recursively because two say functions exist in different translation units. So the submodule strategy doesn't work.
My question is: how is it possible to manage one project that uses two different version of the same static library (*.a)?
Structure
foobar | .----'----. <---- (require) v v foo bar (v1.0) | | (v2.0) '-> say <-' The project foobar require the library foo and the library bar, both of these libraries uses the say package: foo requires version 1 and bar requires version 2.
Packages
say
// say.h void say(char *); foo
// foo.c #include "say.h" void foo(void) { say("I am foo"); } bar
// bar.c #include "say.h" void bar(void) { say("I am bar"); } foobar
// main.c #include <stdlib.h> #include "foo" #include "bar" int main() { foo(); bar(); return EXIT_SUCCESS; }
ldlinker?