Skip to content

Embed as subdirectory

You can use Matplot++ directly in CMake projects as a subproject, without installing it. This is convenient if you are experimenting with this library for the first time or don't expect your users to have Matplot++ installed on their systems.

Check if you have Cmake 3.14+ installed:

1
cmake --version

Clone the whole project

1
git clone https://github.com/alandefreitas/matplotplusplus/

and add the subdirectory to your CMake project:

1
add_subdirectory(matplotplusplus)

When creating your executable, link the library to the targets you want:

1
2
add_executable(my_target main.cpp)
target_link_libraries(my_target PUBLIC matplot)

Add this header to your source files:

1
#include <matplot/matplot.h>

However, in larger projects, it's always recommended to look for Matplot++ with find_package before including it as a subdirectory to avoid ODR errors.