I've been trying to setup the extension library SDL2_image for SDL2 on CLion (MingW). Steps for installation I've taken so far:
- Copy the contents of SDL2_image development into C:\MingW
- Created a FindSDL2_IMAGE.cmake file and linked it.
Here's my CMakeList.txt
file:
cmake_minimum_required(VERSION 3.19)
project(TestGame)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
find_package(SDL2_IMAGE REQUIRED)
include_directories(${SDL2_IMAGE_INCLUDE_DIR})
add_executable(TestGame src/main.cpp src/GameWindow.cpp src/GameWindow.h)
target_link_libraries(TestGame ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
And the relevant main.cpp
file:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int main(int argc, char *args[]) {
IMG_Init(IMG_INIT_PNG);
}
Edit: I've forgot to include the error message.
CMakeFiles\TestGame.dir/objects.a(main.cpp.obj): In function `Z4initv':
D:/_dev/C++/TestGame/src/main.cpp:14: undefined reference to `IMG_Init'