C++ utils linker error

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

C++ utils linker error

Postby snahmad75 » Fri Apr 20, 2018 9:10 am

C:/Work/Actisense/Esp32_http/build/cpp_utils\libcpp_utils.a(WebSocket.o):(.rodata._ZTI23WebSocketInputStreambuf[typeinfo for WebSocketInputStreambuf]+0x8): undefined reference to `typeinfo for std::basic_streambuf<char, std::char_traits<char> >'
collect2.exe: error: ld returned 1 exit status
make: *** [C:/Work/LibDev/esp32/esp-idf/make/project.mk:388: /c/Work/Actisense/Esp32_http/build/app-template.elf] Error 1


I am getting this error when I used HttpServer. I start happening recently. I was compiling before.

#include "HttpServer.h"
#include "HttpRequest.h"
#include "HttpResponse.h"
#include <Task.h>
#include <WiFi.h>
#include <WiFiEventHandler.h>
#include <tcpip_adapter.h>
#include "esp_log.h"
#include "sdkconfig.h"
#include <esp_wifi.h>

extern "C" {
void app_main(void);
}

static WiFi *wifi;




static void helloWorldHandler(HttpRequest* pRequest, HttpResponse* pResponse)
{
printf("helloWorldHandler gets called\n");

pResponse->setStatus(HttpResponse::HTTP_STATUS_OK, "OK");
pResponse->addHeader(HttpRequest::HTTP_HEADER_CONTENT_TYPE, "text/plain");
pResponse->sendData("Hello back");
pResponse->close();
}

class HttpTask: public Task {
void run(void *data) {
ESP_LOGD("http", "Testing http ...");

HttpServer* pHttpServer = new HttpServer();
pHttpServer->addPathHandler(
HttpRequest::HTTP_METHOD_GET,
"/helloWorld",
helloWorldHandler);
pHttpServer->start(80);


return;
}
};

static HttpTask *http_task;

class MyWiFiEventHandler: public WiFiEventHandler {
public:
esp_err_t staGotIp(system_event_sta_got_ip_t event_sta_got_ip)
{
printf("staGotIp\n");

http_task = new HttpTask();
http_task->setStackSize(12000);
http_task->start();

return ESP_OK;
}

esp_err_t apStart()
{
printf("apStart\n");
/*
esp_err_t err = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "mytest");
printf("tcpip_adapter_set_hostname err=%d\n", err);
*/

return ESP_OK;
}
};

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Fri Apr 20, 2018 10:01 am

Hi,

Can some one answer this asap. I am stuck with this error.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Mon Apr 23, 2018 5:04 pm

Can anyone help me with this linker error?

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: C++ utils linker error

Postby chegewara » Mon Apr 23, 2018 11:16 pm

You are missing some reference to this file:
https://github.com/nkolban/esp32-snippe ... cket.h#L21

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Tue Apr 24, 2018 8:38 am

Hi,

I do not know what you mean. I am compiling WebSocket.cpp so there is WebSocket.o file generated.

This is linker error.

Thanks,
Naeem

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Tue Apr 24, 2018 2:31 pm

No linker error If I comment out the code HttpServerTask usage. Any idea how to fix it.

void HttpServer::start(uint16_t portNumber, bool useSSL) {
// Design:
// The start of the HTTP server should be as fast as possible.
ESP_LOGD(LOG_TAG, ">> start: port: %d, useSSL: %d", portNumber, useSSL);

// Take the semaphore that says that we are now running. If we are already running, then end here as
// there is nothing further to do.
if (m_semaphoreServerStarted.take(100, "start") == false) {
ESP_LOGD(LOG_TAG, "<< start: Already running");
return;
}

m_useSSL = useSSL;
m_portNumber = portNumber;

// comment out below two lines to avoid linker error.
//HttpServerTask* pHttpServerTask = new HttpServerTask("HttpServerTask");
//pHttpServerTask->start(this);
ESP_LOGD(LOG_TAG, "<< start");
} // start

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Wed Apr 25, 2018 6:56 pm

This was compiling/building few months back. Is WebSocket.cpp has changed recently?

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: C++ utils linker error

Postby chegewara » Wed Apr 25, 2018 7:04 pm

Looks like its 3 months since last update.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: C++ utils linker error

Postby snahmad75 » Sat Apr 28, 2018 10:01 pm

Hi Guys,

I fixed the issue.

I found out the reason.

I removed -fno-rtti to allow in my components dynamic_cast. I can add -rtti in my own components.mk files.
cpputils needs -fno-rtti . if you need dynamic_cast in your own component than add into your own components.mk -rtti

Don't change esp-idf/make/project.mk



Thanks,
Naeem

Who is online

Users browsing this forum: netfox and 126 guests