Hi, I am trying to use external library and arduino library in platformio everything seems to be ok! but when i try to build the code i got :
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32doit-devkit-v1\firmware.elf] Error 1
here is my code :
#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include <Arduino.h>
TaskHandle_t myTask1Handle = NULL;
TaskHandle_t myTask2Handle = NULL;
SemaphoreHandle_t xSemaphore = NULL;
TaskHandle_t ISR = NULL;
#define LED_PIN_GPIO (gpio_num_t) 2
#define BUTTON_PIN_GPIO (gpio_num_t) 0
#define ESP_INTR_FLAG_DEFAULT 0
void IRAM_ATTR button_isr_handler(void* arg) {
xSemaphoreGiveFromISR(xSemaphore, NULL);
}
void task1(void *arg)
{
while(1){
vTaskDelay(pdMS_TO_TICKS(5000));
//printf("hello from task 1 [%d]\n",xTaskGetTickCount());
// xSemaphoreGive(xSemaphore);
}
}
void task2(void *arg)
{
while(1){
vTaskDelay(pdMS_TO_TICKS(3000));
printf("waiting the button!\n");
if(xSemaphoreTake(xSemaphore,portMAX_DELAY)) {
printf("got message! [%d] \n",xTaskGetTickCount());
}
}
}
void app_main()
{
gpio_pad_select_gpio(BUTTON_PIN_GPIO);
gpio_pad_select_gpio(LED_PIN_GPIO);
// set the correct direction
gpio_set_direction(BUTTON_PIN_GPIO, GPIO_MODE_INPUT);
gpio_set_direction(LED_PIN_GPIO, GPIO_MODE_OUTPUT);
// enable interrupt on falling (1->0) edge for button pin
gpio_set_intr_type(BUTTON_PIN_GPIO, GPIO_INTR_NEGEDGE);
//Install the driver’s GPIO ISR handler service, which allows per-pin GPIO interrupt handlers.
// install ISR service with default configuration
gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
// attach the interrupt service routine
gpio_isr_handler_add(BUTTON_PIN_GPIO, button_isr_handler, NULL);
xSemaphore = xSemaphoreCreateBinary();
xTaskCreate(task1, "task1", 4096, NULL, 10, &myTask1Handle);
xTaskCreatePinnedToCore(task2, "task2", 4096, NULL, 10, &myTask2Handle,1);
}
here is my build error:
> Executing task in folder arduino-blink: C:\Users\HADOUNE\.platformio\penv\Scripts\platformio.exe run <
Processing esp32doit-devkit-v1 (platform: espressif32; framework: arduino; board: esp32doit-devkit-v1)
------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (3.3.1) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)PACKAGES:
- framework-arduinoespressif32 3.10006.210326 (1.0.6)
- tool-esptoolpy 1.30100.210531 (3.1.0)
- toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio\build\esp32doit-devkit-v1\firmware.elf
.pio\build\esp32doit-devkit-v1\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to `setup()'
.pio\build\esp32doit-devkit-v1\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to `loop()'
.pio\build\esp32doit-devkit-v1\libFrameworkArduino.a(main.cpp.o): In function `loopTask(void*)':
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:18: undefined reference to `setup()'
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:21: undefined reference to `loop()'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32doit-devkit-v1\firmware.elf] Error 1
============================ [FAILED] Took 5.30 seconds ============================The terminal process "C:\Users\HADOUNE\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
How can i solve this problem please?