Mike Feldmeier
I've seen variations of this come up in this newsgroup and elsewhere, but I have yet to find an answer that works for me.
class threaded_manager { public: void start(void); };
threaded_manager mgr;
boost::thread(boost::bind(&threaded_manager::start, &mgr));
This consistently produces the linking error:
converter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::thread::thread(class boost::function0
const &)" (__imp_??0thread@boost@@QAE@ABV?$function0@XV?$allocator@Vfunction_bas e@boost@@@_STL@@@1@@Z) referenced in function "public: void __thiscall mytest::test::converter::run(void)" (?run@converter@test@mytest@@QAEXXZ)
I think you aren't linking with the thread library. Many of the Boost libraries (such as Boost.Bind) include their implementation entirely in header files, so they will be compiled into your program as needed. Boost.Thread doesn't; you need to build it as a library (and on Windows it must be a DLL) and link it with your program.
Separating the two boost functions on to separate lines works fine:
boost::bind(&threaded_manager::start, &mgr); boost::thread();
..which indicates to me that bind is returning an object that is not compatible with thread, but I've seen multiple examples of just this type of call. <snip>
If that were the case you should see a compiler error. The two lines above may work because the default constructor for boost::thread is compiled inline whereas the other constructor must be linked in. Having said that, though, neither v1.30 nor v1.31 has the default constructor definition in the header, so I don't entirely understand what's going on. Did you perhaps mistakenly declare a function returning a boost::thread? Ben.