简体   繁体   English

在Linux中链接SFML音频?

[英]Linking SFML audio in linux?

What librarys i need to link when i want to use i have 我想使用时需要链接哪些图书馆

if(! sb.loadFromFile("Intro.wav")){
    exit(-1);
}
intro.setBuffer(sb);
intro.setLoop(true);
intro.play();

I tried with 我尝试过

g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio  Menu.o

but compiler is throwing errors like 但是编译器会抛出类似

undefined reference to `sf::SoundBuffer::SoundBuffer()'
undefined reference to `sf::Sound::Sound()'

The linking order matters. 链接顺序很重要。

I tend to follow the "depends-on" rule. 我倾向于遵循“依赖”规则。 If X depends on Y, then X has to come before Y. All the SFML modules depend on the SFML system module, so the system module needs to come last. 如果X取决于Y,那么X必须先于Y。所有SFML模块都取决于SFML系统模块,因此系统模块需要排在最后。 Additionally you're object files depend on SFML, so they need to come before the SFML libs. 另外,您的目标文件依赖于SFML,因此它们需要位于SFML库之前。

g++ main.o Menu.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-system

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM