[Botan-devel] Re: Problem with Botan LibraryInitializer

Jack Lloyd lloyd at randombit.net
Thu Dec 15 16:23:56 EST 2005


On Thu, Dec 15, 2005 at 03:59:09PM -0500, Carlton Davis wrote:
> Jack,
> 
> I tried putting the following code
> Init::initialize();
> Init::deinitialize();
> in the simulator startup
> and shutdown code, respectively as you suggested,
> but as I anticipated, botan is still throwing the
> Invalid_State exception.
> 
> Perhaps I should ask if it is necessary to initialize the
> botan library before botan variables are declared?

Declared, no. Constructed, yes. That exception is thrown because somewhere some
Botan object is trying to get access to a resource that is global to the
library (typically, the memory pool), and it just found out that nothing is
there yet.

> If the answer to this question is yes, then with the simulator
> I am using (NS2 network simulator), if I initialize the
> botan library in the constructor for the agent (the protocol),
> this won't cause the initialization of botan in the included
> header file. It is hard to explain in a few words; but essentially,
> I don't have access to all the simulation code in C++ because
> the front-end of the simulator is written in octl.

Hmm... well, I admit that I'm still not quite sure what is going on, but I
suppose that's hardly unusual for me. If it really is impossible to get some
C++ hooks executed during process initialization time, the simplest thing that
comes to mind is everywhere you need a global Botan object, keep a pointer to
it instead, and dynamically allocate it after you've had a chance to initialize
the library.

-Jack



More information about the botan-devel mailing list