【问题标题】:SFML Visual Studio 2013 - project wont compileSFML Visual Studio 2013 - 项目无法编译
【发布时间】:2014-09-15 15:12:57
【问题描述】:

我在使用 SFML 库编译项目时遇到问题。在我什至尝试使用 Cmake 自己编译库源但遇到其他问题并且所有库都没有编译之前。因此,我下载了已经为 vc11、x64 编译的库 SFML2.1 并将它们添加到项目属性中,但我收到了一些奇怪的错误,例如:

 Error  5   error LNK1120: 4 unresolved externals   C:\Users\Konrad\Documents\Visual Studio                  2013\Projects\Komparator cen ASG\Debug\Komparator cen ASG.exe  Komparator cen ASG
 Error  4   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Http::~Http(void)" (__imp_??1Http@sf@@QAE@XZ) referenced in function _main  C:\Users\Konrad\Documents\Visual Studio 2013\Projects\Komparator cen ASG\Komparator cen ASG\Main.obj    Komparator cen ASG
 Error  3   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Http::Http(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned short)" (__imp_??0Http@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@G@Z) referenced in function _main    C:\Users\Konrad\Documents\Visual Studio 2013\Projects\Komparator cen ASG\Komparator cen ASG\Main.obj    Komparator cen ASG
 Error  2   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Http::Request::~Request(void)" (__imp_??1Request@Http@sf@@QAE@XZ) referenced in function _main  C:\Users\Konrad\Documents\Visual Studio 2013\Projects\Komparator cen ASG\Komparator cen ASG\Main.obj    Komparator cen ASG
 Error  1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Http::Request::Request(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum sf::Http::Request::Method,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0Request@Http@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Method@012@0@Z) referenced in function _main   C:\Users\Konrad\Documents\Visual Studio 2013\Projects\Komparator cen ASG\Komparator cen ASG\Main.obj    Komparator cen ASG

我尝试编译的代码:

  #include <SFML/Network/Http.hpp>
  #include <string.h>

 using namespace std;

 int main()
 {
     string www = "http://www.gunfire.pl/";
     sf::Http site("http://www.gunfire.pl/");

     sf::Http::Request request(www);
     //request.setUri(www);
     request.Get;

     return 0;
 }

我知道这听起来很奇怪,但我尝试在 VS13 上运行 SFML 库很多次,但已经浪费了很多时间。

【问题讨论】:

  • 这是链接错误,不是编译错误。你确定这个对你没有帮助吗? stackoverflow.com/questions/9788619/…
  • 您是否将 SFML 库文件添加到项目的链接器输入文件中?听起来链接器不知道您正在尝试使用 SFML...
  • 另外,将 vc11 库与 vc12 (VS2013) 一起使用是很危险的——如果 ABI 在版本之间发生变化,可能会由于编译的代码之间的不匹配而导致细微(或不那么细微)的错误在您的项目中,并且代码已经编译到库中。
  • 我个人更喜欢从源代码和我自己的代码构建 SFML;少了很多麻烦。
  • 终于可以使用了,谢谢。已经编译的库对我不起作用,所以我自己编译了动态库。我是否必须将 .dll 文件复制到带有 .exe 文件的文件夹中?无论如何,我在编译 SFML 时还有其他问题:在编译期间它说:无法启动程序 '\...\Cmake-build\lib\Release\sfml-audio-2.dll 有人知道如何解决吗?

标签: c++ sfml


【解决方案1】:

您可以使用为 VS2012(VC11) 编译的库在 VS2013 中编译项目。 但 当你到达 Graphics.draw() 的时候,你会直接遇到问题,因为 SFML 版本不是为 2013 年构建的。

“未解决的外部符号”也是我面临的症状之一。

不幸的是,就这么简单。如果你想在 VS2013 中使用它,你必须自己编译它,正如你所说的。

不幸的是,2013 年有一些错误阻止您构建静态库。

据我所知,目前还没有为 VS2013 构建 SFML 2.1 的解决方案。如果有的话,我会很感兴趣的。

【讨论】:

  • 你可以在这里找到,sfml.my-gate.net/nightly,利用者(SFML 团队成员)的非官方夜间构建。对我来说它有效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-21
  • 1970-01-01
  • 2015-02-21
  • 1970-01-01
  • 2013-07-24
  • 2016-04-05
相关资源
最近更新 更多