how to select the right version of a library

In my efforts to master Arduino I completed several project successfully.

I am now working on a project wilt the multi function board, to create an inclinometer.
I noticed that it uses SoftI2cmaster and SoftI2C libraries, but in the process of learning
Arduino I have now several versions installed of both libraries.
Some came with other software installed, others downloaded from Github, and
this time a local library occurred in the directory of the source for this project.

I got error messages with the compilation and I wonder how the IDE selects which library to use.
How does it select the right library, and how do I know which version of the library has the right
subroutines etc available to complete the project?

Can somebody help to complete this project?

wimvanasperen:
I wonder how the IDE selects which library to use.
How does it select the right library

When multiple libraries are found that match an #include directive in your code, the Arduino IDE tries to be smart about deciding which is the correct library to use. The decision is based on multiple factors:

  • Architecture match between the board (as determined by the architecture folder name of its hardware package) and the library (as determined by the architectures field in library.properties). Explicit match > wildcard match > mismatch. If a library has no library.properties or no architectures field in library.properties, that is considered a wildcard architecture match.
  • Filename/folder name match. If the library folder name matches (or comes close to matching) the filename in the #include directive, that library is given preference.
  • Library location. {sketchbook folder}/libraries > {hardware package folder}/libraries > {Arduino IDE installation folder}/libraries

Libraries bundled with hardware packages other than the one for the board you are compiling for are ignored so they don't even come into the equation.

This system usually does a good job of picking the correct library but in some cases it does end up grabbing a different library than you had intended. To make this less of an issue, the Arduino IDE will display a list of the matching libraries it found and which it used in the black console window at the bottom of the Arduino IDE window. When it thinks the information is not critical, it may only show it if you have File > Preferences > Show verbose output during compilation enabled. So if you're in doubt, it's a good idea to turn that option on at least for one compilation.

In the case of Arduino Web Editor, there may be some additional factors that affect library selection.

wimvanasperen:
how do I know which version of the library has the right
subroutines etc available to complete the project?

Ideally, this would be documented by the author of the project. In the case where the project author has bundled the library with the project, you can be reasonably sure they have designed the project to work with that specific version of the library.

Unfortunately, all too often the authors of projects don't bother to spend a few seconds to document where we can find the library dependencies of the project. In this case, you will need to figure it out yourself by looking at the source code of the project and library, and the library's documentation if it exists.