How to handle common libs in C++/Rust projects

So for example, I have a slightly complicated case of library dependency in one of my projects:

              /--------------------------------\
              |                                |
      /----> GRPC <------------------\         |
      |                              |         |
      |        (c++)                 |         |        
      \-------   A  -------------->  B         |
                 |                 (rust)      |
                 |                             |
                 \------------------> c++  <---/ 

(A is a binary, B is a lib)

Possible solutions:

  1. Set B as a shared library: it works. But B itself contains a complete definition of GRPC, there are potential violation of ODR.
  2. Set B as a static library: Again B itself contains a complete definition of GRPC, so there will be multiple definitions.
  3. Use B as GRPC provider: So I need to maintain GRPC together with B. It is not practical.

(Actually,my current solution is 1, but A even depends on a static libc++ [maybe I should change that], so I think there is a serious ODR violation)

I wonder if anyone is also facing this situation. And any better idea?

This is better suited for users.rust-lang.org. This forum is for the development of Rust.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.