gpt4 book ai didi

c++ - SFML 中的 Visual Studio 错误 :

转载 作者:行者123 更新时间:2023-11-28 05:24:32 27 4
gpt4 key购买 nike

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

最佳答案

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

那么试试这个:

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

结果是:

#include <SFML/Audio.hpp>

关于c++ - SFML 中的 Visual Studio 错误 : <Information not available, 没有为 sfml-audio-d-2.dll 加载符号 >,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40823761/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com