closed source library includes boost distribution
Asked Answered
C

1

9

I'm using a closed source library (by Activ financial) that includes with their API a boost distribution, both some boost header files and boost library files.

I also use Boost in my existing codebase, and I need to use Activ from my existing code.

Some points

  • I can encapsulate my use of Activ so that the entire Activ part amounts to a single class I wrote that does not expose any of Activ's headers
  • This single header file does not use any boost anything
  • In this way I can ensure that the Activ parts of my code use Activ's Boost HPP files, and my code uses my Boost's HPP files

My worry comes in linking. How can I ensure that my Activ dependent code links to Activ's Boost, and my other code links to my Boost?

I'm using g++ now, will also be doing this in VS2008. I got it working in VS2008 before, but I have no idea how everything linked. I want to try to make sure it's done correctly.

Is there a way to do it without further encapsulating the Activ part in a dynamic library?

Edit:

For one, my final product is always an executable file. For two, I statically link to boost myself. The Activ library includes both static and dynamic versions of Boost object libraries, and I plan to statically link it.

I never pass Boost objects between code that uses different boost versions.

The question is, how do I link one cpp or .o file to objects in one library file, and then make sure other .o files link to the identical objects in another library file? Is this possible?

Carline answered 1/12, 2010 at 6:32 Comment(0)
H
3

Does the library dynamically or statically link to Boost? If statically linked, does the library expose the symbols in the DLL (declspec export)?

If the library is statically linked and the symbols are not exposed, and you do not pass any Boost data structures (smart_ptr, threads, etc) back and forth, you are likely safe to use your own version of the Boost library in your DLL.

Hendecahedron answered 1/12, 2010 at 6:37 Comment(1)
See my edit. Basically, it seems I need a hack when linking. I have two object libraries (each version of Boost) that has identical symbols, but non-identical code for those symbols, and I need to make sure that each of my .o files links to the correct Boost .a files. As far as I know, linking can be only be done all-at-once at the end, so I'm not sure what to do. (For the include files, the problem is easier, since I can just compile each cpp file with a different -I directive in gcc.) Am I thinking about this correctly?Carline

© 2022 - 2024 — McMap. All rights reserved.