visual-studio-2010 - XMPP 客户端库 gloox - 链接器找不到符号

标签 visual-studio-2010 linker xmpp symbols gloox

我完全被这个问题难住了,无法真正弄清楚如何解决这个问题。

基本上,我编译了gloox Visual Studio 2010 中的库(只需稍加调整就可以正常工作)并获得一个 .lib 和一个 .dll 文件。我现在尝试在另一个使用大量 gloox 功能的程序中使用它。我能够很好地链接大多数符号,除了一个:

1>test.obj : error LNK2001: unresolved external symbol "class
std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> > 
const gloox::EmptyString" (?EmptyString@gloox@@3V?$basic_string@DU?$
char_traits@D@std@@V?$allocator@D@2@@std@@B)

当我对程序进行详细链接时,我可以看到 gloox lib 中的所有其他符号都链接到了fine:

1>      Searching ..\..\lib\lib\gloox 1.0.lib:
1>        Found "public: virtual __thiscall gloox::Message::~Message(void)" (??       1Message@gloox@@UAE@XZ)
1>          Referenced in test.obj
1>          Loaded gloox 1.0.lib(gloox 1.0.dll)
1>        Found "public: __thiscall gloox::Message::Message(enum   gloox::Message::MessageType,class gloox::JID const &,class std::basic_string<char,struct  std::char_traits<char>,class std::allocator<char> > const &,class  std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Message@gloox@@QAE@W4MessageType@01@ABVJID@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@222@Z)
1>          Referenced in test.obj
1>          Loaded gloox 1.0.lib(gloox 1.0.dll)
1>        Found "public: void __thiscall gloox::ClientBase::registerPresenceHandler(class gloox::PresenceHandler *)" (?registerPresenceHandler@ClientBase@gloox@@QAEXPAVPresenceHandler@2@@Z)
1>          Referenced in test.obj
1>          Loaded gloox 1.0.lib(gloox 1.0.dll)
...

所以我想,可能符号没有正确导出,我这样做了:

dumpbin.exe /exports gloox 1.0.lib

除其他外,我还看到了以下内容:

??_FXHtmlIM@gloox@@QAEXXZ (public: void __thiscall gloox::XHtmlIM::`default constructor closure'(void))
?EmptyString@gloox@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B (class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const gloox::EmptyString)
?GLOOX_CAPS_NODE@gloox@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B (class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const gloox::GLOOX_CAPS_NODE)

第二行显示符号已正常导出。

现在我能想到的唯一区别是正确加载的符号都是函数,而这个特定的函数是一个变量。不过,只要它导出正确,链接器就应该看到它,对吗?

任何帮助将不胜感激。如果您需要更多信息,请告诉我。

谢谢!

最佳答案

旧帖子,但可能对其他人仍然有帮助。

解决方案是确保定义了 GLOOX_IMPORTS。它在 macros.h 中用于定义:

define GLOOX_API __declspec( dllexport )

关于visual-studio-2010 - XMPP 客户端库 gloox - 链接器找不到符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8027727/

相关文章:

c++ - Linux 64 中带有 JsonCPP 库的 undefined symbol 。我缺少什么?

jquery - Openfire 3.9.3 中的消息 Carbon 问题 - 未在所有登录设备中获取 Carbon 消息

c# - 如何在 Entity Framework 4 Designer 中分配默认值并定义唯一键

visual-studio-2010 - Release模式下的断点

c++ - 无法与 boost::locale 链接——objdump 中的奇怪行为

xmpp - OpenFire - 使用 PubSub 的永久群聊

php - 如何在 AWS linux 服务器上安装 ejabberd?

c# - 1分钟倒计时

c++ - VS2010 中的 M_PI : working in Debug conf but not in Release

winapi - 如何在 MASM 中为一个项目编写和组合多个源文件?