I want to port the Infrared Nec example to CPP. I have a linker problem when I include the xRingbufferReceive function.
I have made a small example with the Hello World program.
Code: Select all
#include <stdio.h>
#include "esp_err.h"
#include "esp_log.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "driver/rmt.h"
#include "driver/periph_ctrl.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/ringbuf.h"
void hello_task(void *pvParameter)
{
while(1)
{
RingbufHandle_t rb = NULL;
size_t rx_size = 0;
rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb, &rx_size, 1000);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
extern "C"
{
void app_main()
{
nvs_flash_init();
xTaskCreate(&hello_task, "hello_task", 2048, NULL, 5, NULL);
}
}
LD hello-world.elf
/home/peter/Eigene_dateien/Programmieren/ESP32/hello_world/build/main/libmain.a(hello_world_main.o):(.literal._Z10hello_taskPv+0x0): undefined reference to `xRingbufferReceive(void*, unsigned int*, unsigned int)'
/home/peter/Eigene_dateien/Programmieren/ESP32/hello_world/build/main/libmain.a(hello_world_main.o): In function `hello_task(void*)':
/home/peter/Eigene_dateien/Programmieren/ESP32/hello_world/main/./hello_world_main.cpp:30: undefined reference to `xRingbufferReceive(void*, unsigned int*, unsigned int)'
collect2: error: ld returned 1 exit status
I have just looked into the ringbuf header and I have seen, that there is no extern "C" guard. Can I add it without further problems?
Regards
Peter