Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions tutorials/cppgetstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,43 @@ int main()
}
```

To compile this code on UNIX with pkg-config, use the following command:
To compile the code create a `CMakeLists.txt`:

```{.bash}
c++ $(pkg-config --cflags gz-math8) main.cpp -o main
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
project(gz-math-cpp-example)

find_package(gz-math8 QUIET REQUIRED)

add_executable(gz-math-example main.cpp)
target_link_libraries(gz-math-example PUBLIC gz-math8::gz-math8)
```

The program can then be run as:
Compile the example:

```{.bash}
mkdir build && cd build
cmake ..
```

For Unix systems:

```{.bash}
make

For Windows systems:

```{.bash}
cmake --build . --config Release

Run the example:

```{.bash}
./gz-math-example
```

Output should be:
```{.bash}
$ ./main
Distance from 1 3 5 to 2 4 6 is 1.73205
```

Expand Down
Loading