jeudi 2 avril 2015

CMake SDL : undefined reference to

I'm working on a project using the SDL (v1.2.15-7) and cmake (3.2.1). In the *.h files I added the #include <SDL.h> and when I compile it, I have a bunch of errors : undefined reference to SDL_...


I think the mistake comes from the CMakeLists.txt but I really don't know where.


Here's the file content :



CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )

SET( PROJ_NAME "Project" )
SET( PROJ_PATH ${CMAKE_SOURCE_DIR} )
SET( PROJ_OUT_PATH ${CMAKE_BINARY_DIR} )
SET( PROJ_INCLUDES "include" )

FILE( GLOB_RECURSE PROJ_SOURCES src/*cpp test/*cpp doc/*)
FILE( GLOB_RECURSE PROJ_HEADERS ${PROJ_INCLUDES}/${PROJ_NAME}/*.h )

PROJECT( ${PROJ_NAME} )

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

FIND_PACKAGE( SDL REQUIRED )

SET( PROJ_LIBRARIES ${SDL_LIBS} )

INCLUDE_DIRECTORIES( ${PROJ_INCLUDES} ${SDL_INCLUDE_DIR} )
ADD_EXECUTABLE( ${PROJ_NAME} ${PROJ_SOURCES} ${PROJ_HEADERS} )
TARGET_LINK_LIBRARIES( ${PROJ_NAME} ${PROJ_LIBRARIES} )


If you need more information ask.


PS : I also tried #include SDL/SDL.h


Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire