Httpclient library won't compile on Photon

Hi All,

I’m just tinkering with my new Photon and need to use the the httpclient library from the build.particle.cc library.

I copy the example code to my work space (in build) but the example code will not compile. I’ve made no changes to it.

the final error seems to be:
application.cpp:2:24: fatal error: HttpClient.h: No such file or directory

is it possible the library is not in my workspace? How could I check?

[Update] So i got the “Include in App” function to work this time and it included the library as “HttpClient/HttpClient.h” and the example app will verify, but when I try to flash it to my Proton I get a couple errors that say the functions mills() and delay are not defined in this scope. Well that seems odd…

TIA

Bill

Man, for one of (if not “THE”) most popular lib out there, the fact that the author has not yet fixed it is insane. It was literally a one line fix for me, but also means that I cant use the web ide. Hoepfully he will fix this soon.

Can you share the fix with me? Or are you saying there is no way to compile it without the web IDE?

If you have more info, the Elites can take over the library and work from there :smile:

If someone posts the exact errors I can be sure they are fixed in the firmware (if possible) for the next release which will be today/tomorrow.

@mdma, shouldn’t this be a library fixing issue and nothing related to firmware? :smiley:

If the library worked on the core, and it’s only using our public API then it’s an issue in the firmware. I seem to recall that millis() had the wrong linkage (C++ instead of C) which caused problems in libraries that were redeclaring this function.

1 Like

If you include “application.h” in HttpClient.cpp

#include "HttpClient.h"
#include "application.h"

that fixed the compile problem for me.

2 Likes

Here is the error report when I try to compile the example HTTPClient example for my Photon:

/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp: In member function 'void HttpClient::request(http_request_t&, http_response_t&, http_header_t*, const char*)':
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:172:37: error: 'millis' was not declared in this scope
     unsigned long lastRead = millis();
                                     ^

/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:231:22: error: 'delay' was not declared in this scope
             delay(200);
                      ^

/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:266:47: error: 'atoi' was not declared in this scope
     aResponse.status = atoi(statusCode.c_str());
                                               ^

make[1]: *** [../build/target/user/platform-6HttpClient/HttpClient.o] Error 1
make: *** [user] Error 2

Please use this format to paste code in discourse:

``` <-- insert this

//paste code here

``` <-- insert this

Thanks - in the past I had seen a different error. As @steelydev mentioned, add #include “application.h” to pull in the missing declarations.

@bleddy I think I see your problem: you need to use Particle Dev because you apparently can’t modify library code from build. Or else I don’t know how…

This has been fixed on github (a pull request was merged on July 7). How long does it take to get into the Photon library?

I am not sure, but I just imported it myself today and it worked just fine.

@leon When you say you imported it, you used the HttpClient version from the particle.io web site? or did you clone it from github? Also, did you compile and flash it? If you just use the check compile, it doesn’t complain about the missing libraries.

I just tried compiling and flashing the example app from the HttpClient library on particle.io and I get the same compile error referred to in previous comments (missing library for millis etc). When I import the library from github, it compiles and flashes without error.

I cloned it from github, sorry for the lack of information.
The one on particle.io is still broken when you try flashing.

Hey @Leon,

Yesterday I got the photons and I saw today that the lib is still not compiling.
Can you send the link for the lib in github?

@itayd100
This is the library I am using.


Hope it works for you.

@Leon thanks.
I figure out in the end. It works well with the Core, but I have some problems with the Photon - it stuck as soon as it enters the loop. Do you have any problem with it?

It is supposed to keep repeating, so that should be normal unless you’re trying to do something else.

I have tried using the code from GitHub, but I still get compile issues. Is it as simple a creating a new tab and copying the code into it from GitHub? I am using the Build IDE on Particle.io OR does cloning from GitHub mean something else?

I am writing a program to just go to a google form URL. I don’t need to have any data transfered back, as just requesting the URL from google inputs and submits the data to a spreadsheet.

Thanks!