【问题标题】:Visual Studio error in SFML: <Information not available, no symbols loaded for sfml-audio-d-2.dll>SFML 中的 Visual Studio 错误:<信息不可用,没有为 sfml-audio-d-2.dll 加载符号>
【发布时间】:2017-04-10 23:06:29
【问题描述】:

当我运行代码时,一切正常,只是声音没有播放。链接很好,当我放置断点并查看声音对象时,它会显示 .我在正确的地方添加了 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();
}

}

【问题讨论】:

  • 首先检查loadFromFile的返回值。
  • 运行程序时是否有来自控制台窗口的消息?

标签: c++ audio sfml


【解决方案1】:

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

所以试试这个:

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

结果是:

#include <SFML/Audio.hpp>

【讨论】:

    猜你喜欢
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    • 1970-01-01
    • 2019-06-27
    相关资源
    最近更新 更多