rajat
rajat

Reputation: 3553

Adding a library to cmake

I am trying to compile my project with a library called SDL_draw using cmake . After i download and install it the library files goes to /usr/local/lib and is named libSDL_draw.a ,so i edited the CMakeLists.txt to read this .

link_directories(
    /usr/local/lib
)
include_directories(/usr/local/lib)

ADD_EXECUTABLE(point_trajectory point_trajectory.cpp)

TARGET_LINK_LIBRARIES(point_trajectory SDL_draw)

The cmake succeeds but when i "make" the project after cmake it still cannot find SDL_draw.h .

fatal error: SDL_draw.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/point_trajectory.dir/point_trajectory.cpp.o] Error 1
make[1]: *** [CMakeFiles/point_trajectory.dir/all] Error 2
make: *** [all] Error 2

Upvotes: 2

Views: 6143

Answers (1)

Ray
Ray

Reputation: 930

I have never used SDL_draw before, but something looks funny. Usually the library archive is in /usr/local/lib but the header file is somewhere else ... probably /usr/local/include .

You might want to double-check where SDL_draw.h is. If it is in /usr/local/lib, then double-check that you installed it correctly.

Possibly, this will fix your problem:

include_directories(/usr/local/include)

Upvotes: 3

Related Questions