Hi
I am having trouble with the thread library in the boost package. After I installed it and set up the directories (I am using Visual c++ express 2005 btw) I tried this test program:
However when I compiled this, I got a link error "LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc80-mt-gd-1_33_1.lib'"Code:#include <boost/thread.hpp>
int main()
{
return 0;
}
I checked inside the lib folder and there wasn't a file called libboost_thread-vc80-mt-gd-1_33_1.lib' but there was a file called boost_thread-vc71-mt-gd-1_33_1.lib. So I made a copy of the existing file and renamed it to libboost_thread-vc80-mt-gd-1_33_1.lib. After doing this the above program compiled.
Next I tried this program:
This resulted in the error:Code:#include <boost/thread.hpp>
#include <iostream>
int main()
{
boost::thread_group group;
std::cout<< "hello world";
return 0;
}
Code:msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class
std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"
(??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D
@std@@@0@AAV10@PBD@Z) already defined in Boost Threads.obj
So I (trying to get anything to work) deleted the "std::cout<<"hello world" line and the program compiled.
Finally I tried this program:
This compiled correctly, but when run, it resulted in an assert error:Code:#include <boost/thread.hpp>
#include <iostream>
void testFunction()
{
}
int main()
{
boost::thread_group group;
group.create_thread(&testFunction);
group.join_all();
for(volatile long i = 0; i < 200000000; i++); //delay
return 0;
}
I removed the group.join_all() line and the program ran correctly, but the program outputted:Code:Assertion failed: res == WAIT_OBJECT_0, file D:\Program Files\Boost cpp
Libraries\libs\thread\build\..\src\once.cpp, line 168
It appears that the program still failed, but it quits before the assert has finished. Removing the delay line results in no message, while setting the delay to 800000000 results in the same assertion failure as beforeCode:Assertion failed: res == WAIT_OBJECT_0, file D:\Pro
I am completely stuck with this one and would appreciate any ideas!
(oh and sorry for my huge first post :p)