--- In Boost-Users@y..., "imi123_1999"
I am a newbie so please help me a little. I am using Visual C++ 6.0 in order to compile a program given as an example of threads.
Where did you get the example from? What version of Boost are you using?
I am also copying the program below. But the problem is that the program is giving errors of unresolved externals. Please tell me how to change the settings of VC++ options. Here is the program:
#include
#include <iostream> int count = 0; boost::mutex mutex;
void increment_count() { boost::mutex::lock lock(mutex); std::cout << "count = " << ++count << std::endl; }
int main(int argc, char* argv[]) { boost::thread_group threads; for (int i = 0; i < 10; ++i) threads.create_thread(&increment_count); threads.join_all(); }
The errors i am getting are:
C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2039: 'lock' : is not a member of 'mutex' c:\program files\microsoft visual studio\vc98 \include\boost\thread\mutex.hpp(35) : see declaration of 'mutex' C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2065: 'lock' : undeclared identifier C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2146: syntax error : missing ';' before identifier 'lock' C:\Windows\Desktop\threadImI\imi.cpp(19) : warning C4508: 'main' : function should return a value; 'void' return type assumed Error executing cl.exe. Creating browse info file...
threadImI.exe - 3 error(s), 3 warning(s)
The name "lock" was changed to "scoped_lock" quite some time ago. I don't know where you got the example from, but if it's in the current documentation it needs fixing. Bill Kempf