0

我在我的windows电脑上安装了Stlport,为了在VC10中用Stlport替换Microsoft STL,我将Stlport的头文件添加到Include Directories(Property Pages->VC++ Directories->Include Directories),放入stl_port.lib链接( Linker->Input->Additional Dependencies ),并stlport.dll在搜索目录中。此外,我还定义了以下宏:STLP_DONT_USE_AUTO_LINK;_STLP_LEAKS_PEDANTIC;_STLP_USE_DYNAMIC_LIB(C/C++->Preprocessor Definitions)。

当我调用 STL 函数时,它似乎工作得很好。但是,当我调用依赖于 STL 的第三方库(带有 lib 和 dll)时,会出现 STL 冲突问题。我猜的原因是因为第三方库使用 Microsoft STL。一个典型的错误如下:

Error   2   error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@H@Z) referenced in function _main    C:\Research\OpencvTest\OpencvTest.obj

我也尝试从源代码构建第三方库,但我遇到了类似的链接错误:

grfmt_jpeg2000.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class stlp_std::allocator<char> __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::get_allocator(void)const " (__imp_?get_allocator@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@QBE?AV?$allocator@D@2@XZ) referenced in function "class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > __cdecl stlp_std::operator+<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >(char,class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &)" (??$?HDV?$char_traits@D@stlp_std@@V?$allocator@D@1@@stlp_std@@YA?AV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@0@DABV10@@Z)

我想知道我能做些什么来解决链接错误问题。谢谢!

4

0 回答 0