Two C/C++ libraries calling each others extern functions

Viewed 132

I'm trying to connect two c/c++ projects that depend on each other and this is how I'm doing so far.

Project A: I included some header files from project B. The project compiles into libA.so library.

project B: I included some headers files from project A and added the libA.so library. So this one can call extern functions from project A. The project compiles into libB.a library.

Then a user program adds libB.a library from project B and starts running the code.

The problem is I need to call some of the project B functions from project A. But project B is compiled after project A so I can't include libB.a. Both projects are large and use different build systems, So I can't compile them together.

Is there any way that I can call functions from project B? Or is there any better way to connect the two projects?

1 Answers

When I read and understand your question, it seems that Projects A and B depend on each other, right? This structure is not good.

For overlapping functions, it is recommended to create a new library and refer to it in Projects A and B.

Related