SDL2 program on windows cannot start (runnerw.exe: CreateProcess failed with error 193: %1)

Viewed 17

I downloaded SDL2 release edition from: sdl-github: SDL2-devel-2.24.0-mingw.zip.

The OS is windows 10. Compile environment is MINGW64. IDE is clion.

My CMakeLists.txt file is

cmake_minimum_required(VERSION 3.20)
project(sdl_test)

set(CMAKE_CXX_STANDARD 20)

list(APPEND CMAKE_PREFIX_PATH "D:/lib/SDL2-2.24.0")

MESSAGE(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")

find_package(sdl2 CONFIG REQUIRED)
MESSAGE(STATUS "SDL2_INCLUDE_DIRS is ${SDL2_INCLUDE_DIRS}")
MESSAGE(STATUS "SDL2_LIBRARIES is ${SDL2_LIBRARIES}")

include_directories(${SDL2_INCLUDE_DIRS})
add_executable(sdl_test main.cpp)
target_link_libraries(sdl_test ${SDL2_LIBRARIES}-static)
target_link_libraries(sdl_test ${SDL2_LIBRARIES}main)

The main.cpp file is:

extern "C"{
#include <SDL.h>
};
#include <stdio.h>

int main(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
    printf("SDL initialize ok!");
    SDL_Quit();
    getchar();
    return 0;
}

The program can be compiled with no errors but when running it turns that: runnerw.exe: CreateProcess failed with error 193: %1

0 Answers
Related