I'm currently working on a personnal project and I have an issue with SDL_mixer or Audio
I can compile without any problems but when I try to execute the program I got this error:
"SDL could not initialize: SDL_Error: dsp: No such audio device"
I'm compiling with cmake, this is my CMakeList.txt:
cmake_minimum_required(VERSION 3.0)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
project(R-TYPE)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(SDL2_mixer REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS})
add_executable(
R-TYPE
main.cpp
Render/renderWindow.cpp
Menu/menu.cpp
)
target_link_libraries(R-TYPE ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2_MIXER_LIBRARIES})
this is the function where I got the error from:
int main(int argc, char* args[])
{
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
std::cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
return 84;
}
RenderWindow window("R-TYPE", 1920, 1080);
while (gameRunning)
{
game(window);
}
window.cleanUp();
SDL_Quit();
TTF_Quit();
return 0;
}
I'm on UBUNTU, how can I fix this?
I already tried to install libasound2-dev libpulse-dev but that didn't work
This is caused by manually building SDL2 and/or SDL2_mixer (without having all required dependencies installed).
Installing them from apt
instead fixes the issue. The self-built versions had to be purged from /usr/local
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.