I can run allegro 4 on Code::Blocks and load bitmaps without any issues like so:
#include <allegro.h>
int main() {
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
//load BMP
BITMAP* image = load_bitmap("images/dvdlogo.bmp", NULL);
if (!image) { //if not loaded, err out
return 1;
}
blit(image, screen, 0, 0, 0, 0, image->w, image->h);
readkey();
destroy_bitmap(image);
return 0;
}
END_OF_MAIN()
When I try to run it on CLion, the code executes but I can't figure out how to add a bitmap to my CMake.
Here's the current CMake:
cmake_minimum_required(VERSION 3.24)
project(allegro_test C)
set(CMAKE_C_STANDARD 99)
add_executable(allegro_test main.c)
Lier le programme avec les bibliothèques Allegro
target_link_libraries(allegro_test -lalleg44)
set (R_DIR "/images")
set(CMAKE_MFC_FLAG 1)
add_executable(main WIN32 main.c images)
set_target_properties(main PROPERTIES RESOURCE /images/dvdlogo.bmp)
target_include_directories(allegro_test PRIVATE ${IMAGE_DIR})
Copier le fichier BMP dans le répertoire de build
configure_file(C:/Users/lasbo/CLionProjects/allegro_test/images/dvdlogo.bmp ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
include_directories(${PROJECT_SOURCE_DIR} images)
Does anyone know any way to load bmps with Clion/CMake?
]]>Your working directory is probably off. Try running your program from the directory expected by your program's bitmap loading code. CLion probably has a setting somewhere for working directory at run time.
]]>