[Botan-devel] Problem with Botan LibraryInitializer

Jack Lloyd lloyd at randombit.net
Thu Dec 15 12:31:41 EST 2005

Hi Carlton,

I've got to say, the idea of declaring LibraryInitializer itself as a global
makes me feel a little queasy... but hey, if it works, it works.

There really isn't any way to do what you're looking for directly in
C/C++... is there any way to instead declare init in a source file? If you
declare it as a global in a file, C++ guarantees that the constructor will run
sometime before main() starts (though you still won't be able to construct
global Botan objects safely, because C++ does not specify the order in which
global objects are created).

Is there any way to hook into simulation startup and shutdown? Using
Init::initializer and Init::deinitialize may be easier to use than the
LibraryInitializer object.


On Thu, Dec 15, 2005 at 12:21:13PM -0500, Carlton Davis wrote:
> Hello,
> I am using Botan in a routing protocol I plugged into a network
> simulator. When I try to compile the program, I get this error
> message: "multiple definitions of init". This is due to the line:
> "LibraryInitializer init;" appearing more than once in the included
> header file. I know that Jack mentioned in the Botan tutorial that
> the use of global botan variables is a bad idea, but I can't think
> of a way to avoid using the botan variables in the relevant header
> files because of the way the simulator code is written. My
> question is, is there a way to test if the Botan
> library has been initialized in an included header file,
> before doing the initialization (ie is it possible to do something
> of the sort
>    LibraryInitializer init;
> #endif
> Thanks and best regards,
> -Carlton
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel

More information about the botan-devel mailing list