使用SFML编译一个简单的测试项目时遇到了很大的麻烦。 我看到很多类似于我上网的错误,但我尝试的一切都失败了。
我是静态链接sfml。
在项目的属性中,我添加了SFML头和SFML库的路径。
我已在项目的预处理器选项中定义了SFML_STATIC宏。
我添加了模块及其依赖项,如下所示:
sfml-audio-s.lib sfml-audio-s-d.lib sfml-graphics-s.lib sfml-graphics-s-d.lib sfml-window-s.lib sfml-window-s-d.lib sfml-system-s.lib sfml-system-s-d.lib opengl32.lib freetype.lib jpeg.lib winmm.lib flac.lib vorbis.lib vorbisenc.lib vorbisfile.lib ogg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
我甚至在我的可执行文件夹中添加了dll文件,即使静态构建时没有必要。
这是我的代码:
#include "stdafx.h"
#include <SFML/Audio.hpp>
#include <iostream>
#include <stdlib.h>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "helloo" << std::endl;
sf::SoundBuffer buffer;
if (!buffer.loadFromFile("A4.wav"))
std::cout << "cant open file" << std::endl;
sf::Sound sound;
sound.setBuffer(buffer);
sound.play();
_sleep(5000);
return 42;
}
现在这是我得到的错误:
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::~SoundBuffer(void)" (??1SoundBuffer@sf@@QAE@XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Sound::~Sound(void)" (??1Sound@sf@@UAE@XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::play(void)" (?play@Sound@sf@@QAEXXZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::setBuffer(class sf::SoundBuffer const &)" (?setBuffer@Sound@sf@@QAEXABVSoundBuffer@2@@Z) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Sound::Sound(void)" (??0Sound@sf@@QAE@XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::SoundBuffer::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?loadFromFile@SoundBuffer@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::SoundBuffer(void)" (??0SoundBuffer@sf@@QAE@XZ) referenced in function _wmain
另外的信息:
我正在使用visual studio 2010 express。
我下载了“SFML 2.3 Visual C ++ 10(2010) - 64位”。
任何帮助表示感谢。
编辑:正如我所说,我尝试了很多东西,我已经阅读了 LOT 的堆栈溢出或其他论坛帖子,没有任何效果......我一直坚持现在持续2周了。 我真的很感激一些帮助