Boost in Visual C++ 6.0
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. 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
--- 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
--- In Boost-Users@y..., "bill_kempf"
--- In Boost-Users@y..., "imi123_1999"
wrote: 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?
Ahh... found it. Sorry, the example in the documentation is wrong and will be fixed. Rename "lock" to "scoped_lock" and everything should be fine. Bill Kempf
This is my second post. In the last post i pointed out two errors out
of which one is fixed but the other one is still there.
I am trying to build a sample program on threads in VC++. It compiles
successfully but the linker gives errors of unresolved external
symbols. Please tell me that what "changes" we've to make in VC++ 6
linker options. Please tell me clearly that in which dialog box of
VC++ IDE we have to make changes and how and what changes we've to
made. I am using boost 1_27_0. Program and errors are given below:
********************************************************
The program is:
#include
--- In Boost-Users@y..., "imi123_1999"
This is my second post. In the last post i pointed out two errors out of which one is fixed but the other one is still there.
I am trying to build a sample program on threads in VC++. It compiles successfully but the linker gives errors of unresolved external symbols. Please tell me that what "changes" we've to make in VC++ 6 linker options. Please tell me clearly that in which dialog box of VC++ IDE we have to make changes and how and what changes we've to made. I am using boost 1_27_0. Program and errors are given below:
********************************************************
The program is:
#include
#include <iostream> int count = 0; boost::mutex mutex;
void increment_count() { boost::mutex::scoped_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:
imi.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::mutex::mutex(void)" (??0mutex@boost@@QAE@XZ)
imi.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::mutex::~mutex(void)" (??1mutex@boost@@QAE@XZ)
imi.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::thread_group::~thread_group(void)" (?? 1thread_group@boost@@QAE@XZ)
imi.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread_group::join_all(void)" (? join_all@thread_group@boost@@QAEXXZ)
imi.obj : error LNK2001: unresolved external symbol "public: class boost::thread * __thiscall boost::thread_group::create_thread(class boost::function0
const &)" (?crea te_thread@thread_group@boost@@QAEPAVthread@2@ABV?
$function0@XUempty_function_policy@boost@@Uempty_function_mixin@2@H@2@
@Z)
imi.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::thread_group::thread_group(void)" (?? 0thread_group@boost@@QAE@XZ)
imi.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::lock_error::lock_error(void)" (?? 0lock_error@boost@@QAE@XZ)
imi.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::mutex::do_lock(void)" (? do_lock@mutex@boost@@AAEXXZ)
imi.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::mutex::do_unlock(void)" (? do_unlock@mutex@boost@@AAEXXZ)
Debug/threadImI.exe : fatal error LNK1120: 9 unresolved externals Error executing link.exe.
threadImI.exe - 10 error(s), 0 warning(s)
Have you linked against libboost_thread.lib and boost_threadmon.dll? Bill Kempf
participants (2)
-
bill_kempf
-
imi123_1999