c++ - 出现错误:尝试加载 .ogg 文件时出现“对 `__imp__ZN2sf5 的未定义引用”
问题描述
我已经搜索了很多,特别是在加载 .OGG 文件的编码上没有运气。我正在尝试添加 .ogg 格式的音频文件,但不知道问题出在哪里。
这是我将 .OGG 音频文件添加到项目中的步骤:
我首先将它添加到项目中的音频资产中。当我打开 .OGG 文件时,我收到警告/错误: 如果这很重要,我应该以什么编码加载 .OGG 文件?
- 我试图选择一个没有给我警告的编码,它是“ISO-8859-1”。请注意,我尝试了其他编码,例如 UTF-8、UTF-16、UTF-32、US-ASCII,但没有任何效果。
- 我使用 SFML 将声音文件加载到我选择调用 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);
}
声音.h:
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
class Sound {
public:
Sound();
sf::Sound ExampleSound;
sf::SoundBuffer exSoundBuffer;
}
配置.h:
class Configuration {
public:
Sound* sound = new Sound();
}
机器.cpp:
StateMachine::StateMachine() {
auto* sound = new Sound();
config.sound = sound;
sound->menuSong.play();
}
主.cpp:
int main() {
StateMachine stateMachine;
while (stateMachine.run()) { // run() just runs the program until the user exits.
}
}
这是我尝试运行程序时的错误消息:
解决方案
推荐阅读
- php - 如何在 PHP 中将新记录添加到多维数组中?
- python - 从 Pandas 绘制某些数据点
- css - 填充网格容器,以便始终填充最后一个网格项区域
- javascript - Jquery 拖放项目计数和 Ajax 发布更新
- laravel - Laravel 工厂/播种机创建指定的双重记录
- javascript - Passport User Session not being detected (Angular) on a route
- python - 如何使用功能 API 在 Keras 中调用自定义层
- apache-nifi - 在 NIFI 中如何在没有 CSV 标头的情况下从 CSV 转换为 JSON
- sql - 查询具有多级数据的表
- python - 在 Django 中正确设计以根据用户类型处理表单和视图