0

I used to configure boost already, but this time I have no idea what is causing the problem. I provided some screen shots showing my settings in CodeBlocks (svn7550). I built my Boost library using these commands.

Boost is extracted to F:\ and main folder address is:

F:\boost_1_49_0

Here are the commands:

F:\
F:\ cd Boost_1_44_0
F:\ Boost_1_44_0> bootstrap.bat
F:\ Boost_1_44_0>bjam toolset=gcc --build-type=complete stage

The above didn't do any good so I wrote this and actually compiled just fine:

F:\ Boost_1_44_0>bjam variant=debug,release link=static address-model=32 

and then

F:\boost_1_49_0>bjam toolset=gcc variant=debug,release link=static threading=multi address-model=32 --build-type=complete stage

then when I tried to compile a thread example:

    #include <boost/thread.hpp>
#include <iostream>

void wait(int seconds)
{
  boost::this_thread::sleep(boost::posix_time::seconds(seconds));
}

boost::mutex mutex;

void thread()
{
  for (int i = 0; i < 5; ++i)
  {
    wait(1);
    mutex.lock();
    std::cout << "Thread " << boost::this_thread::get_id() << ": " << i << std::endl;
    mutex.unlock();
  }
}

int main()
{
  boost::thread t1(thread);
  boost::thread t2(thread);
  t1.join();
  t2.join();
}

it failed with these errors:

||=== Boost Example, Debug ===|
obj\Debug\main.o||In function `Z6threadv':|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|18|undefined reference to `_imp___ZN5boost11this_thread6get_idEv'|
obj\Debug\main.o||In function `main':|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|27|undefined reference to `_imp___ZN5boost6thread4joinEv'|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to `_imp___ZN5boost6thread4joinEv'|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to `_imp___ZN5boost6threadD1Ev'|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to `_imp___ZN5boost6threadD1Ev'|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to `_imp___ZN5boost6threadD1Ev'|
D:\Documents and Settings\Master\My Documents\Projects\Boost Example\main.cpp|28|undefined reference to `_imp___ZN5boost6threadD1Ev'|
F:\boost_1_49_0\boost\thread\win32\thread_data.hpp|161|undefined reference to `_imp___ZN5boost11this_thread18interruptible_waitEPvNS_6detail7timeoutE'|
obj\Debug\main.o||In function `thread<void (*)()>':|
F:\boost_1_49_0\boost\thread\detail\thread.hpp|205|undefined reference to `_imp___ZN5boost6thread12start_threadEv'|
||=== Build finished: 9 errors, 0 warnings (0 minutes, 58 seconds) ===|

While the thread example above fails , this snippet compiles just fine:

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}

and these are my CB screenShots at the moment:

http://upload.ustmb.ir/uploads/13336039464.jpg

http://upload.ustmb.ir/uploads/13336039463.jpg

http://upload.ustmb.ir/uploads/13336039462.jpg

http://upload.ustmb.ir/uploads/13336039465.jpg

And this is the contents of my stage/lib folder:

http://upload.ustmb.ir/uploads/13335642651.jpg

Would anyone tell me what the problem is?

halfer
  • 19,824
  • 17
  • 99
  • 186
Hossein
  • 24,202
  • 35
  • 119
  • 224

1 Answers1

4

I used this command for compiling boost:

F:\
F:\ cd Boost_1_44_0
F:\ Boost_1_44_0> bootstrap.bat
F:\ Boost_1_44_0>bjam toolset=gcc --build-type=complete stage variant=debug,release threading=multi link=static 

and the rest of the configs are the same. I just followed the guide here and added the:

#define BOOST_THREAD_USE_LIB

to the first line of my source code, and the errors are gone.

halfer
  • 19,824
  • 17
  • 99
  • 186
Hossein
  • 24,202
  • 35
  • 119
  • 224