SFML中的Visual Studio错误:<information not =“”available,=“”no =“”symbols =“”loaded =“”for =“”sfml-audio-d-2.dll =“”>

时间:2016-11-26 22:25:26

标签: c++ audio sfml

当我运行代码时,一切都有效,除了声音没有播放。链接很好,当我放置一个断点并查看声音对象时,它会显示出来。我在正确的位置添加了sfml-audio-d.lib和sfml-audio.lib。欢迎任何建议。

#include <SFML/Graphics.hpp>
#include "SFML/Audio.hpp"
int main() {

sf::RenderWindow window(sf::VideoMode(600, 600), "SFML Application");

sf::SoundBuffer buffer;
buffer.loadFromFile("magicsound.mp3");

sf::Sound sound;

sound.setBuffer(buffer);
sound.play();

//
sf::Sprite background;

sf::Texture texture;

texture.loadFromFile("crash.jpg");

background.setTexture(texture);

while (window.isOpen()) {

    sf::Event event;
    while (window.pollEvent(event)) {

        if (event.type == sf::Event::Closed)
            window.close();

        if (event.type == sf::Event::Resized)
        {
            sf::FloatRect visibleAre(0, 0, event.size.width, event.size.height);
            window.setView(sf::View(visibleAre)); //background stays default size
            //window can be resized without affecting background
        }
    }

    window.clear();
    window.draw(background);
    window.display();
}

}

1 个答案:

答案 0 :(得分:1)

当您使用引号进行包含时,ide会在项目目录中查找库。如果您的项目目录本身有自己的sfml库,我不知道;但这对我来说就像是一个错字。

所以试试这个:

"SFML/Audio.hpp" --> <SFML/Audio.hpp>

结果是:

#include <SFML/Audio.hpp>