c++static-librariesbox2d.a

How to import `.a` file to CMake in C++?


I've generated libBox2D.a. Now I want to import it to C++ project, but I don't know how. How I can import my libBox2D.a to my project using CMake?


Solution

  • Try this:

    find_library(LIBBOX2D Box2D DIRECTORY)
    

    where replace DIRECTORY with the location of libBox2D.a. Then you can link this library to your executable:

    target_link_libraries(exec ${LIBBOX2D})