可以针对Boost.Thread 1.46.1使用MinGW 4.5.2连接不上 [英] Can't link against Boost.Thread 1.46.1 with MinGW 4.5.2

查看:149
本文介绍了可以针对Boost.Thread 1.46.1使用MinGW 4.5.2连接不上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了使用boost:

I've built boost using:

bjam --toolset=gcc --with-thread stage

每当我试图实际使用Boost.Thread我越来越未定义的引用,尽管我反对它链接。它不会像正则表达式或其他系统Boost库发生。

Whenever I'm trying to actually use Boost.Thread I'm getting undefined references although I link against it. It doesn't happen with other Boost libraries like Regex or System.

>g++ main.cpp -I. -L. -lboost_thread-mgw45-mt-1_46_1
C:\Users\jhasse\AppData\Local\Temp\ccjYfDox.o:main.cpp:(.text+0xf): undefined reference to `_imp___ZN5boost6thread20hardware_concurrencyEv'
collect2: ld returned 1 exit status

程序范例:

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

int main()
{
    std::cout << boost::thread::hardware_concurrency() << std::endl;
}

我在做什么错了?

What am I doing wrong?

推荐答案

尝试添加编译器选项-DBOOST_THREAD_USE_LIB

Try adding the compiler option '-DBOOST_THREAD_USE_LIB'

这篇关于可以针对Boost.Thread 1.46.1使用MinGW 4.5.2连接不上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆