0

I am trying to set up my code to use the allegro libray, I am using the KDEV4 under mandriva, I installed the allegro-dev package. Then whenusing allegro functions in KDevelop it displays the documentation, so he surely found the library.

However when I compile my source I get allegro_init() not declared error, so I checked the CMakeLists.txt file and I think the problem is there:

project(game)
add_executable(game main.cpp)

What I should write to cmake to find and link the library?

I have a general installation where :

  • includes are in /usr/include
  • and libs are in /usr/lib

I installed allegro 4.4 under KDE 4.6.5 mandriva 2011 free, cmake 2.8.4.

If it is not obvious my question is what my CMakeLists.txt should looks like to compile with the allegro included.

Hossein
  • 4,097
  • 2
  • 24
  • 46
Qchmqs
  • 1,803
  • 2
  • 20
  • 29

3 Answers3

4

That's maybe you forget to specify include path or lib path. If your allegro's head files locate in /usr/local/allegro/include ,and allegro's lib file whose name is liballegro.a locate in /usr/local/allegro/lib Add following script resolve your problem perhaps.

INCLUDE_DIRECTORIES(
/usr/local/allegro/include
)

LINK_DIRECTORIES(
   /usr/local/allegro/lib
) 

TARGET_LINK_LIBRARIES(game
liballegro.a 
)
Miroslav Glamuzina
  • 4,472
  • 2
  • 19
  • 33
1

One possible way is to do it like this.

project(game)

add_executable(game main.cpp)

target_link_libraries(game -l{library})

Where {library} is the name if the library which you need to link to your executable.

In your case i think it should be libalegro or something like that.

I suppose there is a better way, but I'm not very experienced with Cmake.

Best regards.

0

actually i found that the right way of doing so is to add a CXX flag to the cmake using:

kdev options 

and use a 'allegro-settings --libs' that will return the right place of the includes and .O

and .a precompilled

sorry guys,thx but i will upvote you all

Miroslav Glamuzina
  • 4,472
  • 2
  • 19
  • 33
Qchmqs
  • 1,803
  • 2
  • 20
  • 29