diff --git a/tutorials/cppgetstarted.md b/tutorials/cppgetstarted.md index 39afb8f7..9fa5a07f 100644 --- a/tutorials/cppgetstarted.md +++ b/tutorials/cppgetstarted.md @@ -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 +``` +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: + +``` +mkdir build && cd build +cmake .. +``` + +For Unix systems: +``` +make +``` + +For Windows systems: +``` +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 ``` + ## Bonus: Vector2 Example The following is an example program that uses Vector2 to perform some simple