2015-10-25 2 views
0

Je fais un projet C++ et allegro5 pour l'université. J'ai compilé la bibliothèque allegro et ça marche bien dans Xcode par exemple. Mais je voulais faire mon projet à Clion et dès que tenter de construire des projets, y compris allegro il renvoie une erreur:projet allegro5 dans CLion, ld: erreur de bibliothèque introuvable

ld: library not found for -lallegro_acodec 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
make[2]: *** [TEST1] Error 1 
make[1]: *** [CMakeFiles/TEST1.dir/all] Error 2 
make: *** [all] Error 2 

CMakeLists.txt:

cmake_minimum_required(VERSION 3.3) 
project(TEST1) 

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

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

INCLUDE_DIRECTORIES(/usr/local/Cellar/allegro/5.0.11/include) 

LINK_DIRECTORIES(/usr/local/Cellar/allegro/5.0.11/lib) 

TARGET_LINK_LIBRARIES(TEST1 
     allegro_acodec 
     allegro_audio 
     allegro_color 
     allegro_dialog 
     allegro_image 
     allegro_main 
     allegro_memfile 
     allegro_physfs 
     allegro_primitives 
     allegro_ttf 
     allegro_font 
     allegro) 

main.cpp:

#include <iostream> 
#include <allegro5/allegro.h> 

using namespace std; 

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

    al_init(); 

    return 0; 
} 

Je travaille sur OSX 10.11. Je n'ai pas trouvé de solution à mon problème. Je vois que allegro et CLion ne sont pas si populaires. Quelqu'un peut-il m'aider à comprendre ce que cette erreur signifie?

+0

Que dans vos '/ usr/local/Cave/allegro/5.0.11/dossier lib'? '.dylib's ou' .a's? – WhiteViking

+0

Il existe des '.dylib's. –

Répondre

2

Vous devez émettre link_directoriesavantadd_executable.

De la documentation sur link_directories:

The command will apply only to targets created after it is called.