New to C++ and in need of some debugging Help

Hey all,

I’m getting this error when compiling and was hoping I could get a little guidance:

In file included from …/inc/spark_wiring.h:30:0,
from application.h:31,
from Adafruit_CharacterOLED.h:4,
from Adafruit_CharacterOLED.cpp:7:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
Adafruit_CharacterOLED.cpp: In member function ‘virtual size_t Adafruit_CharacterOLED::write(uint8_t)’:
Adafruit_CharacterOLED.cpp:243:1: warning: no return statement in function returning non-void [-Wreturn-type]
In file included from …/inc/spark_wiring.h:30:0,
from …/inc/spark_wiring_tcpclient.h:29,
from HttpClient.h:5,
from HttpClient.cpp:1:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
In file included from …/inc/spark_wiring.h:30:0,
from application.h:31,
from Weather.h:19,
from Weather.cpp:2:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
Weather.cpp: In member function ‘weather_response_t Weather::update()’:
Weather.cpp:23:16: error: ‘class HttpClient’ has no member named 'init’
Weather.cpp:24:54: error: no matching function for call to 'HttpClient::get(http_request_t&)'
Weather.cpp:24:54: note: candidates are:
In file included from application.h:45:0,
from Weather.h:19,
from Weather.cpp:2:
HttpClient.h:71:22: note: http_response_t* HttpClient::get(http_request_t*)
HttpClient.h:71:22: note: no known conversion for argument 1 from ‘http_request_t’ to 'http_request_t*'
HttpClient.h:91:22: note: http_response_t* HttpClient::get(http_request_t*, http_header_t*)
HttpClient.h:91:22: note: candidate expects 2 arguments, 1 provided
make: *** [Weather.o] Error 1

ross, is this an arduino library you are porting? It is difficult to understand the output without seeing the actual code. A little more information might help. :smile:

Hah of course. No I’m not porting anything, I’m basically just trying to get this to run before I can modify it for my project:

I messaged the author about it and he wasn’t sure about the error I was getting and suggested I make a post about it.

I’ve added in all of the libraries that are included in the “Full Usage Example” at the bottom of that page. Those being: Adafruit_CharacterOLED, weather(included on that github page), HttpClient.and application.

I can get them to all compile individually, but get the above error when I pull it all together for the app.

Hi @ross,

I have not really worked with either of the HttpClient or Weather libraries, yet.
But by reading your error output

I had a look at the source of those libs and there actually is no “init” methode in the HttpClient, which Weather lib tries to call in its “update” function.
I also don’t quite see why this would be necessary in there, since the HttpClient should have been initialized - in its constructor call - before it was passed over to Weather.update(). Maybe you just try to comment out this code line.

The other error:
The code is

http_response_t response = this->client->get(request); 

but I guess it should be

http_response_t* response = this->client->get(&request);  
// Correctional Edit: http_response_t* (was http_response_t)

since this is the declaration for .get

http_response_t* get(http_request_t *aRequest)

aRequest is expected to be a pointer to http_request_t but is passed in as a http_request_t.

On the other hand I might make a complete fool of me :blush: if someone who has actually worked with these libs has had no problem with what I see as error.
But then I can at least correct my own misconceptions :wink:

I have not looked at the library but HTTPclient sounds like TCPclient to me somehow.

Can take a look tonight if you post the link to the libraries :slight_smile:

The errors are coming from the HTTPclient library and I’m thinking we can change it to the equivalent in spark core

Mayby @coffee could shed some more light on this.

Looking at the yahoo-weather code and the HttpClient code (referenced in of Weather lib), I’d guess that the current version of HttpClient does not fit the one used when yahoo-weather was built.

As mentioned above, I can’t find a HttpClient.init methode and as just realized I can’t even find a HttpClient constructor that does not take any parameters, which would be required to have the sample code working, that is given in the

Annotated code snipped:

   void setup() {
        httpClient = new HttpClient();   // <-- I can't find a constructor taking no parameters in HttpClient.cpp

        lcd = new Adafruit_CharacterOLED(...);

        // weather
        weather.init("781788", httpClient);  // <-- if HttpClient was constructed with host, call to non existent HttpClient.init() would not be required within Weather.init().

@kennethlimcp, Weather lib is linked in the third post and HttpClient in the of Weather lib.

Oh, there id a mistake in the example code…

Remove the init call, but use those arguments in constructor (host, port). This should fix it.

Was was building against a testversion of httpclient.

Thought so :wink:

Thanks @Coffee for the final verdict :+1:

Guys, thanks so much for the help. This community is amazing.

I changed this, as @ScruffR mentioned earlier and used Coffee’s updated example code

I’ve been beating my head against this for a little while now. I’ve got it down to these two errors:

Weather.cpp: In member function ‘weather_response_t Weather::update()’:
Weather.cpp:23:16: error: ‘class HttpClient’ has no member named 'init’
Weather.cpp:24:55: error: conversion from ‘http_response_t*’ to non-scalar type ‘http_response_t’ requested
make: *** [Weather.o] Error 1

1 Like

you might have missed this in @Coffee 's (aka synox) answer.

He has already updated his sample code in the to this

  void setup() {
        httpClient = new HttpClient("781788", httpClient); // <-- this is important now
        // <-- although I think it should rathter be 
        // <-- new HttpClient("", 80); 
        // (comment by Scruff.R)

        lcd = new Adafruit_CharacterOLED(...);

        // weather
        weather.init("781788", &httpClient, true);  // <-- 
        // <-- I guess this is also missing in the, to make it work 
        // (comment by Scruff.R)

Once you have constructed the HttpClient this way just change the line

this->client->init("", 80);

in yahoo_weather.cpp Weather::update() to this

// this->client->init("", 80);

since it’s still there in the current version of yahoo_weather.

And for the second error, I’m sorry I gave you a bad clue.
I had put in the correct declaration of get - which returns a pointer to a http_response_t - but I have just copied the call from Weather::update without looking propperly, since this assumes that get returns a http_response_t rather than a pointer.
So the correct version should look like this (Edit: corrected in previous post for future readers)

http_response_t* response = this->client->get(&request);

And since response is now a pointer and not a http_response_t you will have to change any reference to it accordingly (e.g. response.status into response->status and response.body to response->body).

Sorry for that :blush:

I am sorry, I missed to build it against the correct version of http-client. let me fix and test that before you go on. @ScruffR Thanks for pointing out my error.

Thanks @Coffee, I wish I could be helpful in some way. I am in so far over my head -_-

No big deal @Coffee :+1:

That is what happens with work in progress on all ends :wink:


How’s it coming @ross? Need any help from Spark HQ?

@Teke, I think @Coffee was going to take a look at it and get it up to date with the latest HttpClient. Thanks though!

I just released a new version of the HttpClient that is hopefully more easy to use, and more stable to run (no promises that it’s perfect, but it’s better than it was).

You can find it here:

It doesn’t require any initialisation anymore and has an empty constructor so for this example it should work pretty well.

1 Like

I am updating the library to use instead, i will publish it as soon it is fully tested and httpclient has all the features required.

I added @Coffee’s chunked read implementation to HttpClient and will be making some minor changes today for style, but the functionality should be in place now!

Please see my new library based on, which is more stable and easier to use.

Awesome, thanks @coffee! I’m gonna get into it today. I’ll let you know how it goes

1 Like