I have a problem lunching a thread within a class A for example where the class A is a static member of class B with in a dll. I am using Visual Studio 9 and boost 1.40. Please consider the following code:
mylib.h:
#include <boost/thread.hpp>
#include <windows.h>
#ifdef FOO_STATIC
    #define FOO_API
#else
    #ifdef FOO_EXPORT
    #define FOO_API __declspec(dllexport)
    #else
    #define FOO_API __declspec(dllimport)
    #endif
#endif
class FOO_API foo{
    boost::thread* thrd;
    public:
    foo();
    ~foo();
    void do_work();
};
class FOO_API bar{
    static foo f;
public:
    static foo& instance();
};
mylib.cpp:
#include "mylib.h"
foo::foo() 
{
    thrd = new boost::thread(boost::bind(&foo::do_work,this));
}
foo::~foo(){
    thrd->join();
    delete thrd;
}
void foo::do_work(){
    printf("doing some works\n");
}
foo& bar::instance(){return f;}
foo bar::f;
in the executable application, I have:
main.cpp:
#include "mylib.h"
void main(){
    bar::instance();
}
If I link mylib statically to the executable app, It prints out "doing some works", while if I link it dynamically (dll), it does nothing.
I really appreciate any help.