2010-07-19 18 views
2

是否可以在托管C++ DLL中使用stlport?在托管C++中使用stlport

在我的项目中,我从链接器中得到了几个'未解决的令牌'错误,用于stlport的东西。例如为:

1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000819) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" ([email protected]@[email protected]@[email protected]) 
1>ParentWidget.obj : error LNK2028: unresolved token (0A0008EB) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" ([email protected]@[email protected]@[email protected]) referenced in function "public: class stlp_std::allocator<unsigned short> __thiscall stlp_std::vector<unsigned short,class stlp_std::allocator<unsigned short> >::get_allocator(void)const " ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) 
1>Terra3DViewNet.obj : error LNK2028: unresolved token (0A00087D) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" ([email protected]@[email protected]@[email protected]) referenced in function "public: class stlp_std::allocator<unsigned short> __thiscall stlp_std::vector<unsigned short,class stlp_std::allocator<unsigned short> >::get_allocator(void)const " ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) 
1>moc_ParentWidget.obj : error LNK2028: unresolved token (0A000B9F) "public: __thiscall stlp_std::priv::_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >::~_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >(void)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected]) referenced in function "public: __thiscall stlp_std::priv::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >(unsigned int,class stlp_std::allocator<unsigned short> const &)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected][email protected]@[email protected]@Z) 
1>ParentWidget.obj : error LNK2028: unresolved token (0A000CC2) "public: __thiscall stlp_std::priv::_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >::~_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >(void)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected]) referenced in function "public: __thiscall stlp_std::priv::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >(unsigned int,class stlp_std::allocator<unsigned short> const &)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected][email protected]@[email protected]@Z) 
1>Terra3DViewNet.obj : error LNK2028: unresolved token (0A000C5B) "public: __thiscall stlp_std::priv::_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >::~_STLP_alloc_proxy<unsigned short *,unsigned short,class stlp_std::allocator<unsigned short> >(void)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected]) referenced in function "public: __thiscall stlp_std::priv::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >(unsigned int,class stlp_std::allocator<unsigned short> const &)" ([email protected]?$al[email protected]@[email protected]@@[email protected][email protected]@[email protected][email protected]@[email protected]@Z) 
1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000DE1) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" ([email protected][email protected]@[email protected]@[email protected]) 
1>ParentWidget.obj : error LNK2028: unresolved token (0A000F27) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" ([email protected][email protected]@[email protected]@[email protected]) referenced in function "public: __thiscall stlp_std::priv::_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >::~_Vector_base<unsigned short,class stlp_std::allocator<unsigned short> >(void)" ([email protected][email protected]@[email protected]@@[email protected][email protected]@[email protected]) 
... 

我检查如果功能被包括在STLport的库/ DLL和当前具有稍微不同未修饰名称的功能。所以我想调用约定有什么问题!?有任何想法吗?

+1

当提供不完整的错误消息并且没有提供代码时,它会阻止帮助。 – Cogwheel 2010-07-19 16:21:23

+0

我更新了链接器的错误消息。我希望这有帮助! – 2010-07-19 16:23:18

+0

你使用VC++吗?如果是这样,你有没有试过内置的STL?另外,Qt是否也在混合(我正在从“moc_”中猜测)?把Qt和第三方STL放在.Net之上似乎有些过分...... – Cogwheel 2010-07-19 16:45:57

回答

3

我解决了这个问题。问题在于stlport是使用wchar_t作为内置类型处理的,.NET部分是在没有此选项的情况下编译的。

由于这个wchar_t在.NET中被视为unsigned short并导致无法解析的外部符号。

0

C++编译器使用name mangling,例如。使用MSVC++编译时,“void h(int)”变为“?h @@ YAXH @ Z”6/7

但是,编译器之间甚至编译器版本之间的名称转换不同。您的DLL可能是使用不同的编译器或使用不同名称的较旧版本的编译器编译的。尝试使用您正在使用的编译器重新编译库。

+0

我为项目的所有部分使用Visual Studio 2008。所以我绝对使用相同的编译器和编译器版本。 – 2010-07-20 07:33:08

+0

但您是否也使用Visual Studio 2008编译stlport? – Tomaka17 2010-07-20 07:44:24

+0

当然可以。我使用了StlPort,Qt和我当前项目的相同编译器。所有使用相同的编译器设置(除了CLR的东西)。 – 2010-07-20 08:37:47