【原创】关于STL::_Lockit的问题

本文记录了在VS2005环境中调试STL的map类时遇到的无法解析外部符号错误,并分享了一个简单的解决方案:在程序中定义_lockit构造和析构函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在帮Norains 兄实验map的时候遇到一个问题

在VS2005的环境下调试STL的map类,出现了以下的问题

1>maptest.obj : error LNK2019: 无法解析的外部符号 "public: __cdecl std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAA@XZ),该符号在函数 "protected: static struct std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Node * __cdecl std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Max(struct std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Node *)" (?_Max@?$_Tree@KU?$pair@$$CBKK@std@@U_Kfn@?$map@KKU?$less@K@std@@V?$allocator@K@2@@2@U?$less@K@2@V?$allocator@K@2@@std@@KAPAU_Node@12@PAU312@@Z) 中被引用
1>maptest.obj : error LNK2019: 无法解析的外部符号 "public: __cdecl std::_Lockit::_Lockit(void)" (??0_Lockit@std@@QAA@XZ),该符号在函数 "protected: static struct std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Node * __cdecl std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Max(struct std::_Tree,struct std::map,class std::allocator >::_Kfn,struct std::less,class std::allocator >::_Node *)" (?_Max@?$_Tree@KU?$pair@$$CBKK@std@@U_Kfn@?$map@KKU?$less@K@std@@V?$allocator@K@2@@2@U?$less@K@2@V?$allocator@K@2@@std@@KAPAU_Node@12@PAU312@@Z) 中被引用

一开始研究了好一会,以为是库少了,后来看到一个帖子优快云上的

是wince区的一个老帖子,很多大牛都没有解决这个问题,最后LZ说是lockit的问题

解决办法是在程序中定义一下lockit函数,具体如下:

::_Lockit::_Lockit(){};
::_Lockit::~_Lockit(){};
就build通过了。。目前还没想清楚是什么原理。。。。记录下来供遇到此问题的朋友分享
/usr/include/c++/10/bits/stl_heap.h(356): here instantiation of "void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare &) [with _RandomAccessIterator=__gnu_cxx::__normal_iterator<std::pair<google::protobuf::io::CodedInputStream::Limit, int> *, std::vector<std::pair<google::protobuf::io::CodedInputStream::Limit, int>, std::allocator<std::pair<google::protobuf::io::CodedInputStream::Limit, int>>>>, _Compare=__gnu_cxx::__ops::_Iter_comp_iter<caffe::BatchReindexLayer<float>::pair_sort_first>]" /usr/include/c++/10/bits/stl_algo.h(1671): here instantiation of "void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator=__gnu_cxx::__normal_iterator<std::pair<google::protobuf::io::CodedInputStream::Limit, int> *, std::vector<std::pair<google::protobuf::io::CodedInputStream::Limit, int>, std::allocator<std::pair<google::protobuf::io::CodedInputStream::Limit, int>>>>, _Compare=__gnu_cxx::__ops::_Iter_comp_iter<caffe::BatchReindexLayer<float>::pair_sort_first>]" /usr/include/c++/10/bits/stl_algo.h(1942): here instantiation of "void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator=__gnu_cxx::__normal_iterator<std::pair<google::protobuf::io::CodedInputStream::Limit, int> *, std::vector<std::pair<google::protobuf::io::CodedInputStream::Limit, int>, std::allocator<std::pair<google::protobuf::io::CodedInputStream::Limit, int>>>>, _Compare=__gnu_cxx::__ops::_Iter_comp_iter<caffe::BatchReindexLayer<float>::pair_sort_first>]" /usr/include/c++/10/bits/stl_algo.h(1958): here instantiation of "void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator=__gnu_cxx::__normal_iterator<std::pair<google::protobuf::io::CodedInputStream::Limit, int> *, std::vector<std::pair<google::protobuf::io::CodedInputStream::Limit, i
最新发布
03-15
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值