加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 在VS2010中使用Boost.Pool – 链接器错误

发布时间:2020-12-16 07:30:25 所属栏目:百科 来源:网络整理
导读:Boost.Pool documentation说(强调我的): The Boost Pool library is a header-only library. That means there is no .lib,.dll,or .so to build; just add the Boost directory to your compiler’s include file path,and you should be good to go! 但是
Boost.Pool documentation说(强调我的):

The Boost Pool library is a header-only library. That means there is
no .lib,.dll,or .so to build; just add the Boost directory to your
compiler’s include file path,and you should be good to go!

但是当我尝试在VS2010 SP1中编译这样的代码时:

#include <string>
#include <vector>

#include <boostpoolpool_alloc.hpp>

int main()
{
    typedef std::basic_string<wchar_t,std::char_traits<wchar_t>,boost::pool_allocator<wchar_t>> PoolString;

    std::vector<PoolString> vec;
    for (int i = 0; i < 100; i++)
    {
        PoolString s(L"Some test string. ABCDEF.");
        vec.push_back(s);
    }

    // Release pool memory
    boost::singleton_pool<boost::pool_allocator_tag,sizeof(wchar_t)>::release_memory();

    return 0;
}

我收到了链接器错误:

error LNK1104: cannot open file
‘libboost_thread-vc100-mt-gd-1_49.lib’

Boost.Pool文档是否不正确?
我在这里错过了什么?
我如何使用Boost.Pool?

解决方法

boost :: singleton_pool使用的是一个默认的互斥锁实现,它位于boost :: thread中,不仅仅是头文件.

有关如何删除依赖项的信息,请参阅下面引用的singleton_pool header:

Mutex This class is the type of mutex to use to protect simultaneous access to the underlying Pool. Can be any Boost.Thread Mutex type or boost::details::pool::null_mutex. It is exposed so that users may declare some singleton pools normally (i.e.,with synchronization),but some singleton pools without synchronization (by specifying boost::details::pool::null_mutex) for efficiency reasons. The member typedef mutex exposes the value of this template parameter. The default for this parameter is boost::details::pool::default_mutex which is a synonym for either boost::details::pool::null_mutex (when threading support is turned off in the compiler (so BOOST_HAS_THREADS is not set),or threading support has ben explicitly disabled with BOOST_DISABLE_THREADS (Boost-wide disabling of threads) or BOOST_POOL_NO_MT (this library only)) or for boost::mutex (when threading support is enabled in the compiler).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读