Skip to content

Commit 3b2161b

Browse files
committed
Include instructions for the packages
1 parent f989f18 commit 3b2161b

File tree

1 file changed

+70
-23
lines changed

1 file changed

+70
-23
lines changed

README.md

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,25 @@ If you are interested in understanding how the library works, you can read the d
20232023

20242024
## Integration
20252025

2026-
### Dependencies
2026+
### Binary Packages
2027+
2028+
Get the binary package from the [release section](https://github.com/alandefreitas/matplotplusplus/releases). These binaries refer to the last release version of Matplot++.
2029+
2030+
If you need a more recent version of Matplot++, you can download the [binary packages from the CI artifacts](https://github.com/alandefreitas/matplotplusplus/actions?query=workflow%3AMatplotplusplus+event%3Apush) or build the library [from the source files](#build-from-source).
2031+
2032+
Once the package is installed, you can link your C++ program to the library and include the directories where you installed Matplot++. Unless you changed the default options, the library is likely to be in `/usr/local/` (Linux / Mac OS) or `C:/Program Files/` (Windows).
2033+
2034+
If you are using CMake, you can then find Matplot++ with the usual `find_package` command:
2035+
2036+
```cmake
2037+
find_package(Matplot++ REQUIRED)
2038+
# ...
2039+
target_link_libraries(my_target PUBLIC matplot)
2040+
```
2041+
2042+
### Build from Source
2043+
2044+
#### Dependencies
20272045

20282046
This section lists the dependencies you need before installing Matplot++ from source. The build script will try to find all these dependencies for you:
20292047

@@ -2032,7 +2050,7 @@ This section lists the dependencies you need before installing Matplot++ from so
20322050
* Gnuplot 5.2.6+ (Required at runtime)
20332051

20342052
<details>
2035-
<summary>Linux/Ubuntu/GCC:</summary>
2053+
<summary>Instructions: Linux/Ubuntu/GCC:</summary>
20362054

20372055
Check your GCC version:
20382056

@@ -2072,14 +2090,14 @@ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
20722090
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
20732091
```
20742092

2075-
You can now use `update-alternatives` to set you default `gcc` and `g++`:
2093+
You can now use `update-alternatives` to set your default `gcc` and `g++` to a more recent version:
20762094

20772095
```bash
20782096
update-alternatives --config g++
20792097
update-alternatives --config gcc
20802098
```
20812099

2082-
Check your CMake version:
2100+
Also check your CMake version:
20832101

20842102
```bash
20852103
cmake --version
@@ -2093,20 +2111,25 @@ sudo apt upgrade cmake
20932111

20942112
or download the most recent version from [cmake.org](https://cmake.org/).
20952113

2096-
Later when running CMake, make sure you are using GCC-8 or higher.
2114+
[Later](#build-the-examples) when running CMake, make sure you are using GCC-8 or higher by appending the following options:
20972115

20982116
```bash
20992117
-DCMAKE_C_COMPILER=/usr/bin/gcc-8 -DCMAKE_CXX_COMPILER=/usr/bin/g++-8
21002118
```
21012119

2102-
Install Gnuplot: www.gnuplot.info
2120+
Install Gnuplot 5.2.6+
2121+
2122+
```bash
2123+
sudo apt update
2124+
sudo apt install gnuplot
2125+
```
21032126

2104-
Make sure you mark the option "Add application directory to your PATH environment variable".
2127+
or download the latest version from [www.gnuplot.info](www.gnuplot.info). If you're using an installer, make sure you mark the option "Add application directory to your PATH environment variable".
21052128

21062129
</details>
21072130

21082131
<details>
2109-
<summary>Mac Os/Clang</summary>
2132+
<summary>Instructions: Mac Os/Clang</summary>
21102133

21112134
Check your Clang version:
21122135

@@ -2135,20 +2158,32 @@ sudo brew upgrade cmake
21352158
```
21362159

21372160
or download the most recent version from [cmake.org](https://cmake.org/).
2138-
If building the Python bindings, check your Python version:
2139-
Install Gnuplot: www.gnuplot.info
21402161

2141-
Make sure you mark the option "Add application directory to your PATH environment variable".
2162+
If the last command fails because you don't have [Homebrew](https://brew.sh) on your computer, you can install it with
2163+
2164+
```bash
2165+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2166+
```
2167+
2168+
or you can follow the instructions in [https://brew.sh](https://brew.sh).
2169+
2170+
Install Gnuplot 5.2.6+
2171+
2172+
```bash
2173+
sudo brew install gnuplot
2174+
```
2175+
2176+
or download the latest version from [www.gnuplot.info](www.gnuplot.info). If you're using an installer, make sure you mark the option "Add application directory to your PATH environment variable".
21422177

21432178
</details>
21442179

21452180
<details>
21462181
<summary>Instructions: Windows/MSVC</summary>
21472182

2148-
* Make sure you have a recent version of Visual Studio.
2149-
* Download and install Git.
2150-
* Install CMake from https://cmake.org/download/
2151-
* Install Gnuplot: www.gnuplot.info
2183+
* Make sure you have a recent version of [Visual Studio](https://visualstudio.microsoft.com)
2184+
* Download Git from [https://git-scm.com/download/win](https://git-scm.com/download/win) and install it
2185+
* Download CMake from [https://cmake.org/download/](https://cmake.org/download/) and install it
2186+
* Download Gnuplot from [www.gnuplot.info](www.gnuplot.info) and install it
21522187

21532188
</details>
21542189

@@ -2178,7 +2213,7 @@ There's an extra target `matplot_opengl` with the experimental OpenGL backend. Y
21782213

21792214
You can see all dependencies in [`source/3rd_party/CMakeLists.txt`](source/3rd_party/CMakeLists.txt).
21802215

2181-
### Build the Examples
2216+
#### Build the Examples
21822217

21832218
```bash
21842219
mkdir build
@@ -2187,7 +2222,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release
21872222
cmake --build . -j 2 --config Release
21882223
```
21892224

2190-
### Installing Matplot++ from Source
2225+
#### Installing Matplot++ from Source
21912226

21922227
This will install Matplot++ on your system:
21932228

@@ -2201,7 +2236,7 @@ cmake --install .
22012236

22022237
You might need `sudo` for this last command.
22032238

2204-
### Building the packages
2239+
#### Building the packages
22052240

22062241
This will create packages you can use to install Matplot++ on your system:
22072242

@@ -2216,7 +2251,9 @@ cpack .
22162251

22172252
You might need `sudo` for this last command.
22182253

2219-
### Find it as a CMake Package
2254+
### CMake targets
2255+
2256+
#### Find it as a CMake Package
22202257

22212258
If you have the library installed, you can call
22222259

@@ -2239,7 +2276,7 @@ Add this header to your source files:
22392276
#include <matplot/matplot.h>
22402277
```
22412278

2242-
### Use it as a CMake subdirectory
2279+
#### Use it as a CMake subdirectory
22432280

22442281
You can use Matplot++ directly in CMake projects without installing it. Check if you have [Cmake](http://cmake.org) 3.14+ installed:
22452282

@@ -2272,7 +2309,9 @@ Add this header to your source files:
22722309
#include <matplot/matplot.h>
22732310
```
22742311

2275-
### CMake with Automatic Download
2312+
However, it's always recommended to look for Matplot++ with `find_package` before including it as a subdirectory. Otherwise, we can get [ODR errors](https://en.wikipedia.org/wiki/One_Definition_Rule) in larger projects.
2313+
2314+
#### CMake with Automatic Download
22762315

22772316
Check if you have [Cmake](http://cmake.org) 3.14+ installed:
22782317

@@ -2298,11 +2337,19 @@ Then add this header to your source files:
22982337
#include <matplot/matplot.h>
22992338
```
23002339

2340+
However, it's always recommended to look for Matplot++ with `find_package` before including it as a subdirectory. You can use:
2341+
2342+
```
2343+
option(CPM_USE_LOCAL_PACKAGES "Try `find_package` before downloading dependencies" ON)
2344+
```
2345+
2346+
to let CPM.cmake do that for you. Otherwise, we can get [ODR errors](https://en.wikipedia.org/wiki/One_Definition_Rule) in larger projects.
2347+
23012348
### Other build systems
23022349

2303-
If you want to use it in another build system you can either install the library (Section [*Installing*](#installing)) or you have to rewrite the build script.
2350+
If you want to use it in another build system you can either install the library (Section [*Installing*](#installing)) or you have to somehow rewrite the build script.
23042351

2305-
Your project needs to 1) include the headers and compile all source files in the [`source`](source) directory, and 2) link with the dependencies described in [`source/3rd_party/CMakeLists.txt`](source/3rd_party/CMakeLists.txt).
2352+
If you want to rewrite the build script, your project needs to 1) include the headers and compile all source files in the [`source`](source) directory, and 2) link with the dependencies described in [`source/3rd_party/CMakeLists.txt`](source/3rd_party/CMakeLists.txt).
23062353

23072354
Then add this header to your source files:
23082355

0 commit comments

Comments
 (0)