multiple libraries for "DallasTemperature.h" found


I’ve installed MAX31850_DallasTemp and MAX31850_OneWire libraries to support the adafruit max31850K breakout board with esp8266 but I get the following errors, becaus these libraries are not used by the compiler:

Mehrere Bibliotheken wurden für “DallasTemperature.h” gefunden
Benutzt: D:\Dokumente\Arduino\libraries\DallasTemperature
Nicht benutzt: D:\Dokumente\Arduino\libraries\MAX31850_DallasTemp
Mehrere Bibliotheken wurden für “OneWire.h” gefunden
Benutzt: D:\Dokumente\Arduino\libraries\OneWire
Nicht benutzt: D:\Dokumente\Arduino\libraries\MAX31850_OneWire
Nicht benutzt: C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\OneWire
exit status 1
no matching function for call to ‘DallasTemperature::getAddress(byte [8])’

The compiler does not use the MAX31850 libraries even if I provide the complete fath:

#include <ESP8266WiFi.h>
#include <ESP8266WiFi.h>
// #include <OneWire.h>
// #include <DallasTemperature.h>
// #include “D:\Dokumente\Arduino\libraries\MAX31850_OneWire\OneWire.h”
// #include “D:\Dokumente\Arduino\libraries\MAX31850_DallasTemp\DallasTemperature.h”
#include <D:\Dokumente\Arduino\libraries\MAX31850_OneWire\OneWire.h>
#include <D:\Dokumente\Arduino\libraries\MAX31850_DallasTemp\DallasTemperature.h>

How do I force the compiler to use them???

I have had similar problems in the past and the only way I could find to resolve it was to rename the library you the sketch to use.

You need to rename the library folder, rename the primary include file and source file and then go through all the other library files and rename the primary include file in the #include directives.

Then of course you will have to re-do this every time you synch library updates.

Very inconvenient but if anyone knows a simpler way to resolve such conflicts then I am all ears (or eyes more accurately).

Post a link to where you got the MAX31850_DallasTemp and MAX31850_OneWire libraries from. Please use the chain links icon on the toolbar to make it clickable. Or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

I have installed the libraries using the Library Manger.

The names are

  • MAX31850 DallasTemp by Adafruit version 1.0.0
  • MAX31850 OneWire by Adafruit version 1.0.1

Please find the screenshot …


I really hope there is some other way to do the trick ...

This is indeed a tricky one but I think I have a solution:

Create an empty text file named D:\Dokumente\Arduino\libraries\MAX31850_OneWire\MAX31850_OneWire.h
Create an empty text file named D:\Dokumente\Arduino\libraries\MAX31850_DallasTemp\MAX31850_DallasTemp.h

Make sure they actually have the .h extension. Windows is set to to hide file extensions by default so it’s easy to accidentally create the files named MAX31850_OneWire.h.txt.

Use the following includes:

#include <MAX31850_OneWire.h>
#include <OneWire.h>
#include <MAX31850_DallasTemp.h>
#include <DallasTemperature.h>

Thanks a lot, it seems to work - at least I don't get the error again.

Both DS18B20 get recognized corrrectly, but reading the MAX31850K returns no valid address.

Is there a way to verify the comipler used the correct libraries?

And could you help understanding what happens after adding an include statement that refers to an empty .h file?

I had to do this with an SD library that allowed you to specify a CS pin number in the class constructor.

The standard Arduino SD library does not have this features.

So I renamed that particular SD library to MYSD.

Fortunately the SD libraries are fairly simple and don't seem to be subject to particularly frequent updates if at all.

I forgot to mention that you would also need to modify the library name to MySD in library properties file otherwise Arduino IDE spits the dummy and won't list the library.

Is there a way to verify the comipler used the correct libraries?

Edit the incorrect library file and add this line:

#error The wrong library was used

That's how I tested my suggestion. It worked for me but I didn't fully replicate your environment.

And could you help understanding what happens after adding an include statement that refers to an empty .h file?

It adds the library folder that contains that file to the list of include search paths. Among other criteria, the Arduino IDE normally gives include priority to the folder name that matches the include file name so that's why OneWire/OneWire.h was getting include priority over MAX31850_OneWire/OneWire.h.

PS. If you do edit the libraries with that line be sure to remove it after you're done. Otherwise you might forget you did that and have a lot of confusion later when you try to use the library and it won't compile with this strange error message!

Thank you, again - I think the problem has been solved.
Inspired by your suggestion to edit the DallasTemp.h by deliberately adding a syntax error,
I added a define statement to each of the several DallasTemp.h and OneWire.h files,
like this:

#define MAX31850KDALLASTEMP true

My program should now be able to verfy which libraries are used be using something like this:

if (!MAX31850KDALLASTEMP) Serial.println("Library \"MAX31850_DatllasTemp.h\" loaded!");

This seems to work ...

Is that ok, to just add a #define statement only to the .h file while leaving the .cpp files unchanged?
And how can I check for existing #define statements?

Is that ok, to just add a #define statement only to the .h file while leaving the .cpp files unchanged?

Yes, the sketch and any .cpp file that includes the .h file will have those defined. But keep in mind that only tells you that a file from the MAX31850K_DallasTemperature library was used. It does not tell you that none of the files from the DallasTemperature library were also used.

And how can I check for existing #define statements?

I'd do it with the preprocessor since I want to know before running the program.

You can check if a macro has been defined like this:

//whatever you want to do here

I'd do this:

#error MAX31850K_DallasTemperature library was not used

You can also use #warning instead of #error if for some reason you don't want it to cause compilation to fail but this means you need to have compiler warnings turned on in your File > Preferences and you also need to actually look through the output in the black console window at the bottom of the Arduino IDE window after compiling to see the warning.