【发布时间】:2026-02-22 13:30:01
【问题描述】:
我正在尝试使 sfml 与代码块一起使用。我做了这个视频教程中所说的一切:https://www.youtube.com/watch?v=gEGWO8ug2bY
如果我只添加 SFML/Graphics.hpp,一切正常,所以我的配置还不错。
但是如果我尝试添加 SFML/Audio.hpp(我需要在我的项目中添加声音)并编写“sf::Music background_music;”我得到错误:
||=== Build: Debug in JeudeGo (compiler: GNU GCC Compiler) ===|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|52|undefined reference to `sf::Thread::~Thread()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|70|undefined reference to `sf::Thread::wait()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|59|undefined reference to `sf::Thread::~Thread()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|59|undefined reference to `sf::Thread::~Thread()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|135|undefined reference to `sf::Thread::launch()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|166|undefined reference to `sf::Thread::wait()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundStream.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundStream.cpp|228|undefined reference to `sf::Thread::launch()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(InputSoundFile.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\InputSoundFile.cpp|74|undefined reference to `sf::FileInputStream::FileInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(InputSoundFile.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\InputSoundFile.cpp|79|undefined reference to `sf::FileInputStream::open(std::string const&)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(InputSoundFile.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\InputSoundFile.cpp|117|undefined reference to `sf::MemoryInputStream::MemoryInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(InputSoundFile.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\InputSoundFile.cpp|122|undefined reference to `sf::MemoryInputStream::open(void const*, unsigned int)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|71|undefined reference to `sf::FileInputStream::FileInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|72|undefined reference to `sf::FileInputStream::open(std::string const&)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|78|undefined reference to `sf::FileInputStream::seek(long long)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|84|undefined reference to `sf::FileInputStream::~FileInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|84|undefined reference to `sf::FileInputStream::~FileInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|95|undefined reference to `sf::MemoryInputStream::MemoryInputStream()'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|96|undefined reference to `sf::MemoryInputStream::open(void const*, unsigned int)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundFileFactory.cpp|101|undefined reference to `sf::MemoryInputStream::seek(long long)'|
D:\Info\SFML-2.3\lib\libsfml-audio-s-d.a(SoundFileFactory.cpp.obj):D:\sfml-release\_Sources\SFML\include\SFML\System\MemoryInputStream.hpp|43|undefined reference to `vtable for sf::MemoryInputStream'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_write'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_write' follow|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_readinit'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_readinit'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_read' follow|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_read'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| more undefined references to `oggpack_read' follow|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeinit'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_bytes'|
D:\Info\SFML-2.3\lib\libvorbis.a(info.o):info.c|| undefined reference to `oggpack_writeclear'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
我的链接库(按此顺序):
sfml-graphics-s-d
sfml-window-s-d
sfml-system-s-d
sfml-audio-s-d
sfml-network-s-d
flac
ogg
vorbis
vorbisenc
vorbisfile
openal32
jpeg
freetype
ws2_32
gdi32
opengl32
winmm
还有#defines:
SFML_STATIC
UNICODE
感谢您的帮助!
【问题讨论】:
标签: c++ compilation codeblocks sfml