Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost distributed with closed source library

I have an application that needs to use a certain closed source C++ API. This API is distributed with some bits of Boost, binary library files and all. I like to use Boost in my own code. I can't just use their version of Boost since they did not distribute all the parts of Boost I need. How should I proceed? The target platform is linux, eventually Windows as well.

  • I won't pass Boost objects across the API boundary.
  • I can compile things to object files so that my code uses my boost headers, and the API's code uses its Boost headers. This part seems straightforward.
  • What I don't get: how to link my code to my Boost library files, and API's code to its Boost library files. Do I need to compile my own wrapper around the API -- a wrapper whose headers do not include Boost -- to a dynamic library?? (This is the only way I can think of to do the linking. The symbols in the API's Boost library files should be identical to the symbols in my Boost library files. I have to do the linking in two stages, no? The only way I can link one piece of the program without the rest is by making a dynamic library, no?)
like image 808
Scott Avatar asked Jan 28 '11 04:01

Scott


1 Answers

A given executable can only have one piece of code for each symbol. So if their library uses symbol foo from boost v. 1 and you use the same symbol from boost v. 2, then you will get a clash. There's no easy way to get rid of this clash without changing the symbol. It should be possible to use dynamic execution if you were able to compile the boost code into a dynamic library, but this seems like it would be overkill.

Since, in C++, a symbol is mangled with its class/namespaces, you could also change one of these to get the symbol to change.

like image 78
Dave Avatar answered Oct 13 '22 01:10

Dave