(Linux) Unable to link archives via cmake-Collection of common programming errors

Instead of

include_directories(/usr/lib)
link_libraries(usr/lib/libgsl.a usr/libgslcblas.a)

try

add_executable (targetName main.cpp class1.cc class2.cc)
target_link_libraries(targetName gsl gslcblas)

Where targetName is the name of the output binary you intend to create. The path /usr/lib should already be in the default library search path for CMake, so you shouldn’t have to specify that, but if you did have to specify a custom library path, you would do it like so

link_directories(/some/custom/library/path)

The include_directories CMake directive is used for adding header search paths, not library search paths…

Originally posted 2013-11-09 23:28:32.