0
votes

I have a static library libA.a which contains unresolved symbols (they are also available in another static library libA_dep.a)

I create another shared library libB.so which is linked against libA.a

When the user links her program against libB.so she also needs to link against libA_dep.a, otherwise there are unresolved symbols. For licensing reasons I cannot release libA_dep.a to the user. Is there a way to work-around this? (e.g., to link the libB.so with libA_dep.a and tell the linker to place those symbols into the .so)

1
What's wrong with including those symbols from libA_dep.a that you need into libB.so?Walter
Nothing...How do I do that?Alex Kreimer

1 Answers

0
votes

You can do the following, but this will be quite a bit of work:

Create an empty .cpp containing nothing, compile it. Then link it with the static library, using the --whole-archive option, to produce the shared library. This, essentially, converts the static library to an .so.

What this will end up doing is creating a shared library containing all the code from the static library that your own code uses. Then, you link your main application with the shared library instead of the static library.

You will have to provide the same script that you used to your customer, so that they, themselves, can legally obtain that static library, and convert it to the same shared library that you did, allowing them to run your code that was built against the shared library version.