So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By ProximaB
#72112 Code:
Code: Select all/* RestClient simple GET request
 *
 * by Chris Continanza (csquared)
 */

#include <Ethernet.h>
#include <SPI.h>
#include "RestClient.h"

RestClient client = RestClient("localhost:20949/RestService");

//Setup
void setup() {
  Serial.begin(9600);
  // Connect via DHCP
  Serial.println("connect to network");
  client.dhcp();
/*
  // Can still fall back to manual config:
  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  //the IP address for the shield:
  byte ip[] = { 192, 168, 2, 11 };
  Ethernet.begin(mac,ip);
*/
  Serial.println("Setup!");
}

String response;
void loop(){
  response = "";
  int statusCode = client.get("/get", &response);
  Serial.print("Status code from server: ");
  Serial.println(statusCode);
  Serial.print("Response body from server: ");
  Serial.println(response);
  delay(1000);
}


Error messages:
Code: Select allArchiving built core (caching) in: C:\Users\barte\AppData\Local\Temp\arduino_cache_923006\core\core_esp8266_esp8266_nodemcuv2_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_7b3e88992d3c2979d0fdbc9fc6d2ed2e.a
sketch\RestClient.cpp.o:(.text._ZN10RestClient4dhcpEv+0xc): undefined reference to `RestClient::begin(unsigned char*)'

sketch\RestClient.cpp.o: In function `RestClient::dhcp()':

sketch/RestClient.cpp:70: undefined reference to `RestClient::begin(unsigned char*)'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).


I can't figure out what's going on. Could you help me?
User avatar
By McChubby007
#72134 Err, it's telling you what the error is, from the compiler isn't it?
It's reporting:
undefined reference to `RestClient::begin(unsigned char*)

It can't be much more self explanatory : There is no function called that according to the compiler (to be exact, the linker). And, you are not helping by not stating where you got this restclient library from. I have just googled and there are numerous versions, some which have a dhcp method and some that don't. I get a fully feeling you have bits and pieces of different restclient libraries installed.