When I build my simple project including SDL only, it works fine and an executable is produced. However, as soon as I include sdl_image, mixer or ttf the executable is not produced. I reckon it’s because certain dependencies are not installed, but they should be after running git submodule init update --recursive
right?
cmake_minimum_required(VERSION 3.5)
project(Beluga)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# This assumes you have added SDL as a submodule in external/SDL
add_subdirectory(external/SDL EXCLUDE_FROM_ALL)
# add_subdirectory(external/SDL_image EXCLUDE_FROM_ALL)
# add_subdirectory(external/SDL_mixer EXCLUDE_FROM_ALL)
# add_subdirectory(external/SDL_ttf EXCLUDE_FROM_ALL)
# Create your game executable target as usual
add_executable(Beluga src/main.cpp)
# Link to the actual SDL3 library.
target_link_libraries(Beluga PRIVATE
SDL3::SDL3
# SDL3_image::SDL3_image
# SDL3_mixer::SDL3_mixer
# SDL3_ttf::SDL3_ttf
)
[submodule "external/SDL"]
path = external/SDL
url = https://github.com/libsdl-org/SDL
[submodule "external/SDL_image"]
path = external/SDL_image
url = https://github.com/libsdl-org/SDL_image
[submodule "external/SDL_mixer"]
path = external/SDL_mixer
url = https://github.com/libsdl-org/SDL_mixer
[submodule "external/SDL_ttf"]
path = external/SDL_ttf
url = https://github.com/libsdl-org/SDL_ttf
#include <SDL3/SDL.h>
int main( int argc, char* argv[] )
{
const int WIDTH = 640;
const int HEIGHT = 480;
SDL_Window* window = NULL;
SDL_Renderer *renderer = NULL;
SDL_EVENT_QUIT == false;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0);
renderer = SDL_CreateRenderer(window, NULL);
if (SDL_EVENT_QUIT == true){
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
}
After including sdl_image, I expected a .exe files to be generated after building, but no executable…
DisplayName is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1