How to correctly import allegro5 with cmake in clion? [duplicate]

  allegro, c++, clion, cmake

So, I can import allegro5 librar, but when I run/compile code it shows errors. Have no idea what to do. Also I user arch linux and I installed pacman allegro package. And also clion spots the import and doesn’t ark it as error. What to do?

My cmake

project(allegro)

set(CMAKE_CXX_STANDARD 11)


set(SOURCE_FILES main.cpp)
add_executable(Allegro ${SOURCE_FILES})

Main.cpp

#include <iostream>
#include <allegro5/allegro5.h>
using namespace std;

int main(int argc, char **argv) {

    ALLEGRO_DISPLAY *display = NULL;
    if (!al_init()) {
        fprintf(stderr, "failed to initialize allegro!n");
        return -1;
    }
}

Errors

/home/onix/works/cpp/allegro/main.cpp:8: undefined reference to 'al_install_system'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/Allegro.dir/build.make:103: Allegro] Error 1
make[2]: *** [CMakeFiles/Makefile2:95: CMakeFiles/Allegro.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:102: CMakeFiles/Allegro.dir/rule] Error 2
make: *** [Makefile:137: Allegro] Error 2

Source: Windows Questions C++

LEAVE A COMMENT