在托管 c++ 中使用 stlport

发布于 2024-09-10 23:15:34 字数 4598 浏览 13 评论 0原文

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

在我的项目中,我从 stlport 内容的链接器中收到了几个“未解析的令牌”错误。例如:

1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000819) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$$FQAE@XZ)
1>ParentWidget.obj : error LNK2028: unresolved token (0A0008EB) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$$FQAE@XZ) 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 " (?get_allocator@?$vector@GV?$allocator@G@stlp_std@@@stlp_std@@$$FQBE?AV?$allocator@G@2@XZ)
1>Terra3DViewNet.obj : error LNK2028: unresolved token (0A00087D) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$$FQAE@XZ) 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 " (?get_allocator@?$vector@GV?$allocator@G@stlp_std@@@stlp_std@@$$FQBE?AV?$allocator@G@2@XZ)
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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@IABV?$allocator@G@2@@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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@IABV?$allocator@G@2@@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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@IABV?$allocator@G@2@@Z)
1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000DE1) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" (?deallocate@?$allocator@G@stlp_std@@$$FQAEXPAGI@Z)
1>ParentWidget.obj : error LNK2028: unresolved token (0A000F27) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" (?deallocate@?$allocator@G@stlp_std@@$$FQAEXPAGI@Z) 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)" (??1?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$$FQAE@XZ)
...

我检查了这些函数是否包含在 stlport 库/DLL 中,并且这些函数的未修饰名称略有不同。所以我想调用约定有问题!?有什么想法吗?

Is it possible to use stlport within a Managed C++ DLL?

In my project i get several 'unresolved token'-errors from the linker for stlport stuff. e.g.:

1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000819) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$FQAE@XZ)
1>ParentWidget.obj : error LNK2028: unresolved token (0A0008EB) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$FQAE@XZ) 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 " (?get_allocator@?$vector@GV?$allocator@G@stlp_std@@@stlp_std@@$FQBE?AV?$allocator@G@2@XZ)
1>Terra3DViewNet.obj : error LNK2028: unresolved token (0A00087D) "public: __thiscall stlp_std::allocator<unsigned short>::~allocator<unsigned short>(void)" (??1?$allocator@G@stlp_std@@$FQAE@XZ) 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 " (?get_allocator@?$vector@GV?$allocator@G@stlp_std@@@stlp_std@@$FQBE?AV?$allocator@G@2@XZ)
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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@IABV?$allocator@G@2@@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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@IABV?$allocator@G@2@@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)" (??1?$_STLP_alloc_proxy@PAGGV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@XZ) 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 &)" (??0?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@IABV?$allocator@G@2@@Z)
1>moc_ParentWidget.obj : error LNK2020: unresolved token (0A000DE1) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" (?deallocate@?$allocator@G@stlp_std@@$FQAEXPAGI@Z)
1>ParentWidget.obj : error LNK2028: unresolved token (0A000F27) "public: void __thiscall stlp_std::allocator<unsigned short>::deallocate(unsigned short *,unsigned int)" (?deallocate@?$allocator@G@stlp_std@@$FQAEXPAGI@Z) 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)" (??1?$_Vector_base@GV?$allocator@G@stlp_std@@@priv@stlp_std@@$FQAE@XZ)
...

I checked if the functions are included in the stlport library/DLL and the functions a present with a slightly different undecorated name. So i suppose there's something wrong with calling convention!? Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的奇迹 2024-09-17 23:15:34

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

因此,wchar_t 在 .NET 中被视为无符号短整型,并导致无法解析的外部符号。

I solved the problem. The issue was that the stlport was compiled with wchar_t treated as built-in type and the .NET part was compiled without this option.

Because of this wchar_t was treated as unsigned short in .NET and caused the unresolved external symbols.

心意如水 2024-09-17 23:15:34

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

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

C++ compilators use name mangling, eg. "void h(int)" becomes "?h@@YAXH@Z" when compiling with MSVC++ 6/7

However the name conversions differ between compilers, and even between compiler versions. Your DLL was probably compiled with a different compiler or an older version of the compiler which used different names. Try to recompile the library with the compiler you're using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文