[英]Having issue in configuring boost with codeblocks
I used to configure boost already, but this time I have no idea what is causing the problem.我以前已经配置了 boost,但这次我不知道是什么导致了问题。 I provided some screen shots showing my settings in CodeBlocks (svn7550).我提供了一些屏幕截图,显示了我在 CodeBlocks (svn7550) 中的设置。 I built my Boost library using these commands.我使用这些命令构建了我的 Boost 库。
Boost is extracted to F:\
and main folder address is: Boost解压到F:\
,主文件夹地址为:
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:这些是我目前的 CB 屏幕截图:
http://upload.ustmb.ir/uploads/13336039464.jpg http://upload.ustmb.ir/uploads/13336039464.jpg
http://upload.ustmb.ir/uploads/13336039463.jpg http://upload.ustmb.ir/uploads/13336039463.jpg
http://upload.ustmb.ir/uploads/13336039462.jpg http://upload.ustmb.ir/uploads/13336039462.jpg
http://upload.ustmb.ir/uploads/13336039465.jpg http://upload.ustmb.ir/uploads/13336039465.jpg
And this is the contents of my stage/lib folder:这是我的 stage/lib 文件夹的内容:
http://upload.ustmb.ir/uploads/13335642651.jpg http://upload.ustmb.ir/uploads/13335642651.jpg
Would anyone tell me what the problem is?谁能告诉我问题出在哪里?
I used this command for compiling boost:我用这个命令来编译 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.和配置的 rest 是相同的。 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.到我的源代码的第一行,错误就消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.