3

I'm trying to add a static library to my C++/ROS project and having trouble wondering where to start. I have the project currently working with a CMake file to build it and have downloaded (and can build) an external static library that I want to use in the project.

I am very new to CMake and C++ in general and am working on a project that I haven't created myself. I've read a lot of tutorials on how to add libraries but I'm stuck at knowing where to start as I know there are many different steps needed. I was looking at find_library(), add_library() and ExternalProject_Add() but I don't really understand the difference and the documentation doesn't make it much clearer. As it stands the CMake file has very little in it so I was wondering what exactly I need to add and what commands are best just to be able to use this library in my project. Specifically, I guess what set of commands would I add to a pretty empty CMake file for it to work given I have the lib.a file. Sorry for the vagueness but any help would be appreciated.

Ghasem Ramezani
  • 2,683
  • 1
  • 13
  • 32
TheAddie
  • 73
  • 1
  • 6
  • 1
    Use `include_directories` or `target_include_directories` command for add a directory with the library header (yes, aside from `lib.a` you need to have its header file(s)) to the list of include directories of your library/executable. As for linking with external library, see [that question](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library). – Tsyvarev Sep 06 '21 at 07:35

0 Answers0