SFGUI/C++ 编译问题。错误 2019:未解析的外部符号

Posted

技术标签:

【中文标题】SFGUI/C++ 编译问题。错误 2019:未解析的外部符号【英文标题】:SFGUI/C++ Compiling problems. Error 2019: unresolved external symbol 【发布时间】:2014-06-23 15:04:49 【问题描述】:

我正在尝试编译 SFGUI 库 - 它是 SFML 的 GUI。我按照这些说明进行操作 http://sfgui.sfml-dev.de/p/docs/guide/installing 。

首先我使用 CMake 生成 makefile - 我将生成器设置为 NMake Makefiles,然后是 Visual Studio 2012。然后我尝试使用 NMake 和 Visual Studio 2013 对其进行编译。两者都产生了相同的错误,如下所示。

Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)const " (__imp_?begin@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ) referenced in function "public: class sf::Vector2<float> __thiscall sfg::Engine::GetTextMetricsA(class sf::String const &,class sf::Font const &,unsigned int)const " (?GetTextMetricsA@Engine@sfg@@QBE?AV?$Vector2@M@sf@@ABVString@4@ABVFont@4@I@Z) C:\Program Files (x86)\CMake 2.8\bin\Engine.obj sfgui
Error   2   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)const " (__imp_?begin@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Renderer.obj   sfgui
Error   3   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)const " (__imp_?begin@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Window.cpp.obj sfgui
Error   4   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)const " (__imp_?begin@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Entry.cpp.obj  sfgui
Error   5   error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)const " (__imp_?end@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ) referenced in function "public: class sf::Vector2<float> __thiscall sfg::Engine::GetTextMetricsA(class sf::String const &,class sf::Font const &,unsigned int)const " (?GetTextMetricsA@Engine@sfg@@QBE?AV?$Vector2@M@sf@@ABVString@4@ABVFont@4@I@Z) C:\Program Files (x86)\CMake 2.8\bin\Engine.obj sfgui
Error   6   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)const " (__imp_?end@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Renderer.obj   sfgui
Error   7   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)const " (__imp_?end@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Window.cpp.obj sfgui
Error   8   error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)const " (__imp_?end@String@sf@@QBE?AV?$_String_const_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)  C:\Program Files (x86)\CMake 2.8\bin\Entry.cpp.obj  sfgui
Error   9   error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::_String_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)" (__imp_?begin@String@sf@@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ) referenced in function "private: unsigned int __thiscall sfg::Entry::GetPositionFromMouseX(int)" (?GetPositionFromMouseX@Entry@sfg@@AAEIH@Z)   C:\Program Files (x86)\CMake 2.8\bin\Entry.cpp.obj  sfgui
Error   10  error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::begin(void)" (__imp_?begin@String@sf@@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)    C:\Program Files (x86)\CMake 2.8\bin\Label.cpp.obj  sfgui
Error   11  error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::_String_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)" (__imp_?end@String@sf@@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ) referenced in function "private: unsigned int __thiscall sfg::Entry::GetPositionFromMouseX(int)" (?GetPositionFromMouseX@Entry@sfg@@AAEIH@Z)   C:\Program Files (x86)\CMake 2.8\bin\Entry.cpp.obj  sfgui
Error   12  error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::_String_iterator<class std::_String_val<struct std::_Simple_types<unsigned int> > > __thiscall sf::String::end(void)" (__imp_?end@String@sf@@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ)    C:\Program Files (x86)\CMake 2.8\bin\Label.cpp.obj  sfgui
Error   13  error LNK1120: 4 unresolved externals   C:\Program Files (x86)\CMake 2.8\bin\Debug\sfgui-d.dll  sfgui

你知道怎么解决吗?我在互联网上搜索答案,但它没有帮助我。它是库,不是我的项目,所以我不应该更改代码。

【问题讨论】:

我只是喜欢链接器错误消息——清晰和可读性的本质。 【参考方案1】:

这个类sf::String不是由SFGUI本身提供的,而是由底层的跨平台库SFML提供的。似乎它的库没有正确包含在构建中。

确保在 CMake 运行期间正确找到 SFML,检查其 .lib 二进制文件是否在正确的位置生成(不仅仅是包含),查看运行时是否指定了这些库 @987654322 @ 在nmake VERBOSE=1 等的输出中。还要重新检查 SFML 之前是否正确构建,检查其中可能的安装步骤等等。

【讨论】:

以上是关于SFGUI/C++ 编译问题。错误 2019:未解析的外部符号的主要内容,如果未能解决你的问题,请参考以下文章

XCode 6 Beta 6 Beta 7 中的错误 - 可选类型的值未解包

谁有奇闻怪事未解之迷的资料

未解锁锁定的互斥锁

matlab暂时未解的问题

未解之谜

NFS未解之谜之IO持续占用问题