The code is:
> #include “main.h”
>
> SDL_Window* gWindow = nullptr;
>
> int main() {
> int errcode;
> if ((errcode = SDL_Init(SDL_INIT_VIDEO))) {
> printf(“error: sdl failed to init. (%d)\n”,errcode);
> goto end;
> }
>
> if((errcode = IMG_Init( IMG_INIT_PNG )) != IMG_INIT_PNG) {
> printf(“error: failed to init image. (%d) (%s)\n”,errcode, SDL_GetError());
> goto end;
> }
>
> gWindow = SDL_CreateWindow(“wtf just test”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
> if(gWindow == nullptr) {
> printf(“error: failed to create window.”);
> goto end;
> }
> SDL_Delay(5000);
> end:
> return false;
> }
And output is:
error: failed to init image. (0) (PNG images are not supported)
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(foo)
set(ToBuild “bin/foo”)
set(CMAKE_EXE_LINKER_FLAGS “-static-libgcc -static-libstdc++”)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} “${CMAKE_SOURCE_DIR}/cmake/”)
aux_source_directory(src DIR_SRC)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
add_executable(${ToBuild} ${DIR_SRC})
target_link_libraries(${ToBuild} ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY})
Anyway to fix it?
(I’m using Solus Linux)