mDNS library fails to build in 0.6.2 but works in versions before

I try to build the mdns.ino example with the mDNS library from Particle Build. If I target for 0.6.1 it compiles successfully but in 0.6.2 it gives an error.

Googling didn’t give me any clue how to fix this and I’m also curious why this breaks in 0.6.2.

Build errors:
/workspace/lib/MDNS/src/Record.h:143:44: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)' void addEntry(String key, String value = NULL);

/workspace/lib/MDNS/src/MDNS.h:24:47: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)' void addTXTEntry(String key, String value = NULL);

@mrhornsby You seem to maintain this library, maybe you have an idea?

It compiles without errors when I compile it with the offline compiler.

Hi kasper,

I’ve not tried compiling this in a while. Having a look through the release notes mentions something about arduino compatibility and including the Arduino.h header. Given that the compilation failures are against the signatures in the headers as well this could be related - can you try adding the Arduino.h header and see if that resolves the issue?


1 Like

Hi Mark,
I’ve tried adding #include "Arduino.h" on top of the example file. Because I think I can’t edit libraries in Particle build (and offline it works…).

This threw an additional error. So there might be a bug in the online builder?

../wiring/inc/spark_wiring_arduino_constants.h:111:18: error: expected unqualified-id before '(' token #define max(a,b) ((a)>(b)?(a):(b))

This is an issue in the Particle firmware

1 Like

Thanks. Sorry I’ve missed that.

@mrhornsby Thanks for updating the code. Did you also synchronised it with Particle (particle library upload and particle library publish <my_lib> ? Because the build still gives the old version.

I’ve uploaded a new version (1.3.2) that handles the old format (String x = NULL) but defaults to an empty string. This will work on v0.6.2 and should have exactly the same behaviour as before.


1 Like

I get another error with 1.3.2 in build:
/workspace//src/mdns.cpp:1:18: fatal error: MDNS.h: No such file or directory #include "application.h" ^
It think you should include Particle.h nowadays.

Did you add the library to your project using the cli:

particle library add mdns

I’ve just created a new project with my sample ino and the above command and it compiles successfully.


I was using However now it builds fine. Thanks!

Yup, I have noticed this behaviour too. After adding a library you sometimes get this message but a few seconds or edits later it builds fine. Just as if adding the library takes its time to trickle through to your project :wink:

1 Like

Another question. I’ve noticed I couldn’t reach my host “myphoton.local” anymore, while it gave back a success.
I removed the addService line, after that I could reach my server again. Putting the line back after that again, and now I can reach myphoton still good.

So this is a kind of non-producable bug. I’m curious what it could be and how I possibly can prevent it.

const String hostname   = "myphoton";

bool mdns_success = mdns.setHostname(hostname);

	if(mdns_success) {
			mdns.addService("tcp", "http", 80, hostname);

Whole code: