I just installed Boost on my machine. I’m working with the Visual Studio 2010 Ultimate. To install Boost I followed the instruction here: http://www.boost.org/doc/libs/1_48_0/more/getting_started/windows.html. In particular this line: “The installers supplied by BoostPro Computing will download and install pre-compiled binaries into the lib\ subdirectory of the boost root”. So I found I have boost_1_47 now running on my machine. And I started a little test program, to play with the boost::thread library. However this code which is the FIRST example code on the introduction to boost::thread won’t compile:
#include <boost/thread.hpp>
boost::thread make_thread();
void f()
{
boost::thread some_thread = make_thread();
some_thread.join();
}
int main()
{
f();
return 0;
}
This is the error message:
error LNK2019: unresolved external symbol "class boost::thread __cdecl make_thread(void)" (?make_thread@@YA?AVthread@boost@@XZ) referenced in function "void __cdecl f(void)" (?f@@YAXXZ)
However this code compiles:
#include <boost/thread.hpp>
void testFunction()
{
}
int main()
{
boost::thread_group group;
group.create_thread(&testFunction);
group.join_all();
return 0;
}
The above code I copy/pasted from some forum entry. But what is the reason for all this? Is make_thread() not supported by version 47? If so, why does only the linker complain then? What am I missing?
EDIT:
My apologies for having asked this question, I find it hard to admit, but this belongs to the category RTFM. But however stumbles about this: read the answers below.
After a quick search on Google, and reading the documentation about thread management, it seems to me that the function
make_threadis just a dummy function used in an example to show that threads can be moved between different thread objects.If you want a specific function that creates a thread, you have to make it yourself.