Error: Can not start thread: error writing TLS. (error 87: the parameter is incorrect.)
When I tried building an multi-thread TUI application using wxWidgets framework, I got the following error while executing the application.
Error: Can not start thread: error writing TLS. (error 87: the parameter is incorrect.)
I was not able to reason out this behavior. I tried changing between THREAD_DETACHABLE and THREAD_JOINABLE, but was not able to get through. When I search for hints from the web, I got the following link.
http://osdir.com/ml/lib.wxwindows.general/2004-01/msg00759.html
It was advised to create a dummy wxInitializer object so that the wxWidgets platform does the necessary initialization. wxInitializer class is an undocumented class and called internally when a wxFrame or wxDialog based GUI application is built. Typically, wxInitializer object is instantiated internally by the wxApp class. Since, in my application there is no wxApp object which led to the above problem
When I dug the declaration of wxInitializer class, I found it declared at wx/init.h; Also I found that instead of instantiating the object, we may call the following function.
extern bool WXDLLIMPEXP_BASE wxInitialize(int argc = 0, wxChar **argv = NULL);
In my application, I did the following:
main( int argc, char **argv )
{
extern bool wxInitialize( int, char ** );
wxInitialize( argc, argv );
….
….
}
It worked like piece of cream.

Powered by ScribeFire.