尝试加载.ogg文件时出现错误:“对`__imp__ZN2sf5的未定义引用”

我搜索了很多内容,没有运气,尤其是在加载.OGG文件的编码方面。我正在尝试以.ogg格式添加音频文件,却不知道问题出在哪里。

这是将.OGG音频文件添加到项目中的步骤:

  1. 我首先将其添加到项目中的音频资产中。当我打开.OGG文件时,出现警告/错误:

    尝试加载.ogg文件时出现错误:“对`__imp__ZN2sf5的未定义引用”

    如果重要的话,我应该以哪种编码方式加载.OGG文件?

    • 我试图选择一种没有发出警告的编码,即“ ISO-8859-1”。请注意,我尝试使用其他编码,例如UTF-8,UTF-16,utf-32,US-ASCII,没有任何效果。

这是UTF-8编码(默认)的.OGG文件的图片:

尝试加载.ogg文件时出现错误:“对`__imp__ZN2sf5的未定义引用”

  1. 我使用SFML将声音文件加载到我选择调用Sound的类中:

Sound.cpp:

#include "Sound.h"

Sound::Sound() {
    const std::string pathToProject = "C:\\Users\\User\\projectName";

    exSongbuffer.loadFromFile(pathToProject + "\\projectContainer\\Assets\\Sounds\\ExampleSound.ogg");
        exampleSong.setBuffer(exSongbuffer);
    }

Sound.h:

#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp>

class Sound {
public:
    Sound();

    sf::Sound ExampleSound;
    sf::SoundBuffer exSoundBuffer;
}

Configuration.h:

class Configuration {
public:
    Sound* sound = new Sound();
}

Machine.cpp:

StateMachine::StateMachine() {
    auto* sound = new Sound();
    config.sound = sound;
    sound->menuSong.play();
}

main.cpp:

int main() {
   StateMachine stateMachine;
   while (stateMachine.run()) { // run() just runs the program until the user exits.

   }
}    

这是我尝试运行程序时的错误消息:

尝试加载.ogg文件时出现错误:“对`__imp__ZN2sf5的未定义引用”

jiayibeibao 回答:尝试加载.ogg文件时出现错误:“对`__imp__ZN2sf5的未定义引用”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3058840.html

大家都在问