0

when I try to use the SFML-Audio library, I get this error:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: __cdecl sf::SoundBuffer::~SoundBuffer(void)" (__imp_??1SoundBuffer@sf@@QEAA@XZ)   War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: bool __cdecl sf::SoundBuffer::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?loadFromFile@SoundBuffer@sf@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)  War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: __cdecl sf::SoundBuffer::SoundBuffer(void)" (__imp_??0SoundBuffer@sf@@QEAA@XZ)    War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: void __cdecl sf::Sound::setBuffer(class sf::SoundBuffer const &)" (__imp_?setBuffer@Sound@sf@@QEAAXAEBVSoundBuffer@2@@Z)  War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl sf::Sound::play(void)" (__imp_?play@Sound@sf@@UEAAXXZ)   War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: virtual __cdecl sf::Sound::~Sound(void)" (__imp_??1Sound@sf@@UEAA@XZ) War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK2001 unresolved external symbol "__declspec(dllimport) public: __cdecl sf::Sound::Sound(void)" (__imp_??0Sound@sf@@QEAA@XZ)  War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\main.obj  1   
Error   LNK1120 7 unresolved externals  War-Tech    C:\Users\domon\Documents\myfiless\MyProjects\War-Tech\x64\Release\War-Tech.exe  1   

My included libraries:

sfml-graphics.lib
sfml-window.lib
sfml-system.lib
sfml-audio-s.lib
sfml-system-s.lib
sfml-audio-s-d.lib
openal32.lib
opengl32.lib
winmm.lib

Please help me, I've been struggling with this problem for a long time, I can't seem to get the sound to play in the game.SFML itself works correctly, but for some reason SFML-Audio does not work for me :(

Sound code:

sf::SoundBuffer buffer;

if (!buffer.loadFromFile("main.wav"))
{
    std::cout << "ERROR" << std::endl;
}

sf::Sound sound;

sound.setBuffer(buffer);

sound.play();
vvvvv
  • 25,404
  • 19
  • 49
  • 81
domon41c
  • 11
  • 5
  • 1
    The -s libraries are meant to statically link sfml into your program. But the link error message clearly shows you want to dllimport the function. So you have to link sfml-audio.lib. Don't also link the -d library, that's the debug build. – Hans Passant Nov 27 '22 at 00:14
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Nov 27 '22 at 00:25
  • How did I understand this because I don't link the library correctly, and instead of a static type of library I use a debug library? @Hans Passant – domon41c Nov 27 '22 at 07:17

1 Answers1

0

Just include sfml-audio.lib instead of sfml-audio-d.lib

domon41c
  • 11
  • 5