Skip to content

Bring back library example#7430

Merged
DennisOSRM merged 15 commits intoProject-OSRM:masterfrom
jfaustino:bring-back-library-example
Mar 28, 2026
Merged

Bring back library example#7430
DennisOSRM merged 15 commits intoProject-OSRM:masterfrom
jfaustino:bring-back-library-example

Conversation

@jfaustino
Copy link
Copy Markdown
Contributor

Issue

Adresses #7266. No tests or changelog because it doesn't change the library itself, but I think the wiki may be improved.

Tasklist

Requirements / Relations

N/A

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reintroduces and documents OSRM “library usage” examples by adding a C++ libosrm sample, a CMake find-module for libosrm, and refreshing the Node.js example and documentation.

Changes:

  • Modernize example/example.js to ESM imports and update its Monaco query example.
  • Add a C++ libosrm routing example (example/example.cpp) plus a CMake FindLibOSRM.cmake.
  • Add new documentation (docs/libosrm.md) and an example/README.md describing how to build/run the examples.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
example/example.js Converts the Node.js example to ESM, updates threadpool sizing and example query URL.
example/example.cpp Adds a standalone C++ libosrm “Route” example using EngineConfig + OSRM::Route.
example/cmake/FindLibOSRM.cmake Introduces a pkg-config-based CMake find-module for locating libosrm.
example/README.md Adds instructions for preparing test data and building/running the examples.
docs/libosrm.md Adds introductory documentation for using OSRM as a C++ library.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread example/cmake/FindLibOSRM.cmake
Comment thread example/cmake/FindLibOSRM.cmake Outdated
Comment thread example/README.md Outdated
Comment thread docs/libosrm.md
Comment thread docs/libosrm.md
Comment thread example/example.cpp
Comment thread example/example.js Outdated
Comment thread example/example.js
Comment thread docs/libosrm.md Outdated
Comment thread docs/libosrm.md
OSRM can be used as a library (libosrm) via C++ instead of using it through the HTTP interface and `osrm-routed`. This allows for fine-tuning OSRM and has much less overhead. Here is a quick introduction into how to use `libosrm` in the upcoming v5 release.

Take a look at the example code that lives in the [example directory](https://github.com/Project-OSRM/osrm-backend/tree/master/example). Here is all you ever wanted to know about `libosrm`, that is a short description of what the types do and where to find documentation on it:

Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This new page isn’t linked from the VitePress nav/sidebar (see docs/.vitepress/config.js), and there don’t appear to be other docs linking to /libosrm yet. Add it to the docs navigation (or at least link it from docs/index.md) so users can discover it in the rendered documentation site.

Suggested change
For a general overview of OSRM and its HTTP API, see the [main documentation](./index.md).

Copilot uses AI. Check for mistakes.
@DennisOSRM
Copy link
Copy Markdown
Collaborator

Looking good. There is one minor nitpick when compiling the example. A warning gets issues on duplicate linker flags:

$ make
[ 50%] Building CXX object CMakeFiles/osrm-example.dir/example.cpp.o
[100%] Linking CXX executable osrm-example
ld: warning: ignoring duplicate libraries: '-losrm'
[100%] Built target osrm-example

@jfaustino
Copy link
Copy Markdown
Contributor Author

Looking good. There is one minor nitpick when compiling the example. A warning gets issues on duplicate linker flags:

$ make
[ 50%] Building CXX object CMakeFiles/osrm-example.dir/example.cpp.o
[100%] Linking CXX executable osrm-example
ld: warning: ignoring duplicate libraries: '-losrm'
[100%] Built target osrm-example

I couldn't see the warning, but I found the duplicate entry in ./CMakeFiles/osrm-example.dir/link.txt.

Regarding the linking to the libosrm.md, I'm thinking of only adding it on the sidebar, like in the old docs.

Copy link
Copy Markdown
Collaborator

@DennisOSRM DennisOSRM left a comment

Choose a reason for hiding this comment

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

Looking good.

@DennisOSRM
Copy link
Copy Markdown
Collaborator

Regarding the linking to the libosrm.md, I'm thinking of only adding it on the sidebar, like in the old docs.

That makes sense.

@DennisOSRM DennisOSRM merged commit b94847b into Project-OSRM:master Mar 28, 2026
23 checks passed
@jfaustino jfaustino deleted the bring-back-library-example branch April 10, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants