I have a C++ project on a Linux VM.
The project runs fine in Visual C++ on my Win8.1. The project has pngs.
On the VM cmake … and make work but the program stops when it has to render the pngs.
This is the error I get:
SDL_Surface* loadedSurface = IMG_Load(path.c_str());
if (loadedSurface == NULL)
{printf(“Unable to load image %s! SDL_image Error: %s\n”, path.c_str(), IMG_GetError());}
And this is the CMakeLists I made:
cmake_minimum_required(VERSION 3.7)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-std=c++17)
set(CXX_FLAGS “-Wall”)
set(CMAKE_CXX_FLAGS, “${CXX_FLAGS}”)
project(CrazyTown)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} “${CMAKE_SOURCE_DIR}/cmake/”)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} src)
include_directories(${SDL2_IMAGE_DIRS} src)
add_executable(CrazyTown src/main.cpp src/game.cpp src/texture.cpp src/streets.cpp src/random.cpp src/car.cpp src/buttons.cpp src/house.cpp)
target_link_libraries(CrazyTown ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
I ran the following command:sudo apt-get install libsdl2-image-dev
I have a cmake folder that contains FindSDL2.cmake and FindSDL2_image.cmake
There are some dll files that I should include.
Please tell me how I should proceed.
Thanks.