找到你要的答案

Q:Visual Studio SFML Linker Error [duplicate]

Q:Visual Studio SFML链接错误[复制]

I am new to SFML and when I tried to compile a basic program, I'd get this error

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) void >__cdecl sf::sleep(class sf::Time)" (__imp_?sleep@sf@@YAXVTime@1@@Z) referenced in> >function _main C:\Users\asd\documents\visual studio 2013\Projects\OpenGL\OpenGL\Source.obj OpenGL

Here's the code:

#include <SFML/System.hpp>
#define SFML_STATIC

int main()
{
  sf::sleep(sf::seconds(1.f));
  return 0;
}

I also linked the sfml-windows-s.lib and sfml-system-s.lib

这个问题在这里已经有了答案:

我是新来的,当我试图SFML编写基本的程序,我得到这个错误

错误2:错误lnk2019未解决的外部符号”__declspec(dllimport)无效>;__cdecl SF::睡眠(类科幻::时间)”(__imp_?睡眠@ SF @ @ yaxvtime @ 1 @ @ Z)在& gt参考;>;功能_main C:\用户\ ASD \文件\ Visual Studio 2013 \项目\ \ \ source.obj OpenGL OpenGL OpenGL

这是代码:

#include <SFML/System.hpp>
#define SFML_STATIC

int main()
{
  sf::sleep(sf::seconds(1.f));
  return 0;
}

我又联系了sfml-windows-s.lib和sfml-system-s.lib

answer1: 回答1:

I had to define SFML_STATIC as a preprocessor instead of inside the code.

我已经定义sfml_static里面的代码预处理器代替。

c++  visual-studio  opengl  visual-studio-2013  sfml