Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorial build step #626

Open
wants to merge 3 commits into
base: gz-math8
Choose a base branch
from
Open
Changes from 2 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
38 changes: 33 additions & 5 deletions tutorials/cppgetstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,47 @@ 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
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```{.bash}

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 ${GZ-MATH_LIBRARIES})
alesof marked this conversation as resolved.
Show resolved Hide resolved
```

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

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```{.bash}

mkdir build && cd build
cmake ..
```

For Unix systems:
```
make
```
Comment on lines +89 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For Unix systems:
```
make
```
For Unix systems:
```{.bash}
make


For Windows systems:
```
cmake --build . --config Release
```
Comment on lines +94 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For Windows systems:
```
cmake --build . --config Release
```
For Windows systems:
```{.bash}
cmake --build . --config Release


Run the example:

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

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


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this new line

## Bonus: Vector2 Example

The following is an example program that uses Vector2 to perform some simple
Expand Down