#include <stdlib.h>
#include "SDL.h"
#include "SDL/SDL_mixer.h"
int main (int argc, char ** argv) {
if(SDL_Init(SDL_INIT_AUDIO)==-1) {
fprintf(stderr, "SDL_Init: %s\n", SDL_GetError());
exit(1);
}
if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
fprintf(stderr, "Mix_OpenAudio: %s\n", Mix_GetError());
exit(1);
}
return 0;
}
运行以后终端显示:
Mix_OpenAudio: No available audio device
ubuntu 下SDL 声音无法播放,我的电脑能正常听哥的。 Mix_OpenAudio: No...
”apt-get install libasound2-dev libpulse-dev“安装库 并且重新配置你sdl库,重新编译你的应用程序!