views:

47

answers:

1

The program that I am working on is statically linked to a 3rdPartyLibrary.lib.

We wanted to take advantage of a newer version of the same 3rdPartyLibrary, say 3rdPartyLibraryNewVersion.lib.

So the decision is to include the 3rdPartyLibraryNewVersion.so as a dynamically linked library, to be included via a wrapper dynamic library called wrapper.so. We are hoping to use both the new version and old version of the 3rdPartyLibrary at the same time, but in different party of the program.

The solution we have is to statically link the old 3rdPartyLibrary and dynamically linked to a wrapper library to the 3rdPartyLibraryNewVersion at the same time.

program --- statically linked ---> 3rdPartyLibrary.lib. --- dynamically linked --> wrapper.so --- dynamically linked ---> 3rdPartyLibraryNewVersion.so.

Is this possible?

The problem that we encountered is that while the wrapper.so worked with a test executable, it failed inside the 3rdPartyLibraryNewVersion.so when the wrapper is invoked from the program which is statically linked to the 3rdPartyLibrary.lib.

Did I do anything wrong?

I know the correct way is to update our code to 3rdPartyLibrary.lib but it is too tedious...

Thanks,

Tim

+1  A: 

You neglect to mention how it failed using your wrapper scheme...

However you do it you will probably run into namespace collisions that will cause things to either fail or behave in unexpected ways.

You know the right thing to do: update your code. If it's too tedious then your code must not be worth the effort. If you must have to code working with new features, then it's worth updating. The last thing you want is to create a situation where you are now tied to two different and incompatible versions of the same library. If you have to maintain it later you will kick yourself. If someone else has to maintain it they will hunt you down and beat you. Do it the right way.

dwc
I know we are going down a slippery path, but the alternate path is not easy.In any case, the core file from the program indicated the program crashed inside the 3rdPartyLibraryNewVersion.so, according to gdb. A few internal calls in the 3rdPartyLibraryNewVersion were made before a SIGSEGV were sent.Would you be able to elaborate on the namespace collisions?The wrapper library that is linked in will make call to the 3rdPartyLibraryNewVersion (or so I think), do you mean that the program will be confused and called the statically linked library?