简体   繁体   中英

How to add allegro Library in Clion and CMake?

I am trying to compile my game project using Clion IDE but I have a problem when porting allegro 5. I get this error:

main.cpp:2:10: fatal error: 'allegro/allegro.h' file not found
   #include <allegro/allegro.h>

My CMakeLists is:

cmake_minimum_required(VERSION 3.5)
project(testAllegro)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

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

INCLUDE_DIRECTORIES(  /usr/local/include )
LINK_DIRECTORIES(  /usr/local/lib )

file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")

TARGET_LINK_LIBRARIES(testAllegro  ${LIBRARIES})

Just I want to ask how can I add external Library allegro to Clion?

when you install allegro using homebrew link

use this cmake to compile clion project

cmake_minimum_required(VERSION 3.5)
project(testAllegro)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

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

INCLUDE_DIRECTORIES(  /usr/local/Cellar/allegro/5.2.1.1_1/include )
LINK_DIRECTORIES(  /usr/local/Cellar/allegro/5.2.1.1_1/lib )

file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")

TARGET_LINK_LIBRARIES(testAllegro  ${LIBRARIES})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM