PlatformIO Community

Problem using external library

Hi,
I have a zip library that works perfectly in Arduino IDE, same in platformio tool with arduino firmware, but when i try to use it with idf espressif firmware in platformio, the compiler doesn’t recognize stuff like Arduino.h, WProgram.h, HardwareSerial…etc, I am trying to find a solution to my problem but in vain, it’s been more than 20 days none of the proposed solutions have worked for me, I have tried :
to include the library with a tree format ;
to modifiy platformio.ini with
platform_packages =

platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

but in vain;
to change cmakelist compiler path;
to change sdkconfig.h configuration.
none of this solution worked for me.
This is my last chance to get it work! if you have any idea i would be greatful.
Here is the library link : Servo

As expected with a normal ESP-IDF setup – you don’t have access to the Arduino layer if you not specificially add some instructions to the platformio.ini. See https://github.com/platformio/platform-espressif32/tree/develop/examples/espidf-arduino-blink as a starting point.

Actually, it works now, but if i want to use it with void app_main(), so i can use freertos/semafore and other idf epsressif specific syntax, I got this error!
appearently, i can’t use read Arduino library while using idf espressif firmware!!
here is the error:

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...
Dependency Graph
|-- <SCServo-master> 0.0.0+20210817123422
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\Blink.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSCL.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSerail.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSBL.cpp.o
src\Blink.cpp: In function 'void app_main()':
src\Blink.cpp:67:56: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
   gpio_set_direction(CONFIG_BUTTON_PIN, GPIO_MODE_INPUT);
                                                        ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:346:11: note:   initializing argument 1 of 'esp_err_t gpio_set_direction(gpio_num_t, gpio_mode_t)'
 esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
           ^
src\Blink.cpp:68:56: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
     gpio_set_direction(CONFIG_LED_PIN, GPIO_MODE_OUTPUT);
                                                        ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:346:11: note:   initializing argument 1 of 'esp_err_t gpio_set_direction(gpio_num_t, gpio_mode_t)'
 esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
           ^
src\Blink.cpp:71:58: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
   gpio_set_intr_type(CONFIG_BUTTON_PIN, GPIO_INTR_NEGEDGE);
                                                          ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:274:11: note:   initializing argument 1 of 'esp_err_t gpio_set_intr_type(gpio_num_t, gpio_int_type_t)'
 esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);      
           ^
src\Blink.cpp:79:67: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
   gpio_isr_handler_add(CONFIG_BUTTON_PIN, button_isr_handler, NULL);
                                                                   ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:503:11: note:   initializing argument 1 of 'esp_err_t gpio_isr_handler_add(gpio_num_t, gpio_isr_t, void*)'
 esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void* args);
           ^
*** [.pio\build\esp32doit-devkit-v1\src\Blink.cpp.o] Error 1
============================ [FAILED] Took 3.43 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.

Since you are working in a .cpp file, conversion rules are much more strict. You need to add explicit (gpio_num_t) casts before CONFIG_BUTTON_PIN.

Just like the example does in

still getting the same error!
here is my code that includes the added library!

/*


#include <stdio.h>

#include "driver/gpio.h"

#include "freertos/FreeRTOS.h"

#include "freertos/task.h"

#include "freertos/semphr.h"

#include <Arduino.h>

#include <SCServo.h>

#define BLINK_GPIO (gpio_num_t)CONFIG_BLINK_GPIO

// Set LED_BUILTIN if it is not defined by Arduino framework

// #define LED_BUILTIN 2

TaskHandle_t myTask1Handle = NULL;

TaskHandle_t myTask2Handle = NULL;

SemaphoreHandle_t xSemaphore = NULL;

TaskHandle_t ISR = NULL;

#define CONFIG_LED_PIN 2

#define ESP_INTR_FLAG_DEFAULT 0

#define CONFIG_BUTTON_PIN 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(CONFIG_BUTTON_PIN);

  gpio_pad_select_gpio(CONFIG_LED_PIN);

  

  // set the correct direction

  gpio_set_direction(CONFIG_BUTTON_PIN, GPIO_MODE_INPUT);

    gpio_set_direction(CONFIG_LED_PIN, GPIO_MODE_OUTPUT);

  

  // enable interrupt on falling (1->0) edge for button pin

  gpio_set_intr_type(CONFIG_BUTTON_PIN, 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(CONFIG_BUTTON_PIN, button_isr_handler, NULL);

xSemaphore = xSemaphoreCreateBinary();

    xTaskCreate(task1, "task1", 4096, NULL, 10, &myTask1Handle);

   xTaskCreatePinnedToCore(task2, "task2", 4096, NULL, 10, &myTask2Handle,1);

}

Where are all the casts to gpio_num_t? You didn’t put it there or in the macro definition.

Actually, this is the first time i want to use Idf espressif firmware! i’am used to use arduino firmware, what do i have to do with gpio_num_t? or where do i have to put it ?

The reference project does

#define BLINK_GPIO (gpio_num_t)CONFIG_BLINK_GPIO

you do

#define CONFIG_LED_PIN 2
#define CONFIG_BUTTON_PIN 0

adapt accordingly.

unfortunately, i couldn’t make it work, here is my proposition,

#define LED_PIN_GPIO (2)CONFIG_LED_PIN_GPIO

#define BUTTON_PIN_GPIO (0)CONFIG_BUTTON_PIN_GPIO

#define ESP_INTR_FLAG_DEFAULT 0

here is the error i am getting :

src\Blink.cpp: In function 'void app_main()':
src\Blink.cpp:28:25: error: expected ')' before 'CONFIG_LED_PIN_GPIO'
 #define LED_PIN_GPIO (2)CONFIG_LED_PIN_GPIO
                         ^
src\Blink.cpp:73:22: note: in expansion of macro 'LED_PIN_GPIO'
   gpio_set_direction(LED_PIN_GPIO, GPIO_MODE_INPUT);
                      ^
src\Blink.cpp:73:51: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
   gpio_set_direction(LED_PIN_GPIO, GPIO_MODE_INPUT);
                                                   ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:346:11: note:   initializing argument 1 of 'esp_err_t gpio_set_direction(gpio_num_t, gpio_mode_t)'
 esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
           ^
src\Blink.cpp:29:28: error: expected ')' before 'CONFIG_BUTTON_PIN_GPIO'
 #define BUTTON_PIN_GPIO (0)CONFIG_BUTTON_PIN_GPIO
                            ^
src\Blink.cpp:74:24: note: in expansion of macro 'BUTTON_PIN_GPIO'
     gpio_set_direction(BUTTON_PIN_GPIO, GPIO_MODE_OUTPUT);
                        ^
src\Blink.cpp:74:57: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
     gpio_set_direction(BUTTON_PIN_GPIO, GPIO_MODE_OUTPUT);
                                                         ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:346:11: note:   initializing argument 1 of 'esp_err_t gpio_set_direction(gpio_num_t, gpio_mode_t)'
 esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
           ^
src\Blink.cpp:29:28: error: expected ')' before 'CONFIG_BUTTON_PIN_GPIO'
 #define BUTTON_PIN_GPIO (0)CONFIG_BUTTON_PIN_GPIO
                            ^
src\Blink.cpp:77:22: note: in expansion of macro 'BUTTON_PIN_GPIO'
   gpio_set_intr_type(BUTTON_PIN_GPIO, GPIO_INTR_NEGEDGE);
                      ^
src\Blink.cpp:77:56: error: invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]
   gpio_set_intr_type(BUTTON_PIN_GPIO, GPIO_INTR_NEGEDGE);
                                                        ^
In file included from src\Blink.cpp:8:0:
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\driver/driver/gpio.h:274:11: note:   initializing argument 1 of 'esp_err_t gpio_set_intr_type(gpio_num_t, gpio_int_type_t)'
 esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);      
           ^
src\Blink.cpp:85:24: error: 'CONFIG_BUTTON_PIN' was not declared in this scope      
   gpio_isr_handler_add(CONFIG_BUTTON_PIN, button_isr_handler, NULL);
                        ^
*** [.pio\build\esp32doit-devkit-v1\src\Blink.cpp.o] Error 1
============================ [FAILED] Took 3.39 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.

i couldn’t figure out what gpio_num_t is for? I’ve searched in different sites but there is not much information about this error!

That’s not valid C++ code, you’re attempting to cast CONFIG_PIN_GPIO to the type “2”, which is not a type. As previously said, the type casts to gpio_num_t are missing, so it goes from

#define CONFIG_LED_PIN 2
#define CONFIG_BUTTON_PIN 0

to

#define CONFIG_LED_PIN (gpio_num_t) 2
#define CONFIG_BUTTON_PIN (gpio_num_t) 0

I understand now, here is the only error i am getting right now:


Warning! Ignore unknown configuration option `-d config_led_pin_gpio` in section [env:esp32doit-devkit-v1]
Warning! Ignore unknown configuration option `-d config_button_pin_gpio` in section 
[env:esp32doit-devkit-v1]
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...
Dependency Graph
|-- <SCServo-master> 0.0.0+20210817123422
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\Blink.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSCL.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSerail.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSBL.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSCL.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Indexing .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-log.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c: In function 'spiTransferBytesNL':
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_out8 = &result[c_longs-1];
                                       ^
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_data8 = &last_data;
                                        ^
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
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 19.13 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.

What is your platformio.ini Looks to me like you didn’t correctly indent the command into the list of build flags.

here is my platformio.ini :

 
; PlatformIO Project Configuration File

;

;   Build options: build flags, source filter, extra scripting

;   Upload options: custom port, speed and extra flags

;   Library options: dependencies, extra library storages

;

; Please visit documentation for the other options and examples

; http://docs.platformio.org/page/projectconf.html

[env:esp32doit-devkit-v1]

platform = espressif32

framework = arduino

board = esp32doit-devkit-v1

monitor_speed = 115200

build_flags =

-D LED_PIN_GPIO=2

-D BUTTON_PIN_GPIO = 0

If you put multiple options in build_flags as new lines, each line must be indented at least two spaces from the left. Just as it says in the documentation.

done! but still getting this error! :

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...
Dependency Graph
|-- <SCServo-master> 0.0.0+20210817123422
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\Blink.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSCL.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSerail.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSBL.cpp.o
src\Blink.cpp:28:0: warning: "LED_PIN_GPIO" redefined
 #define LED_PIN_GPIO (gpio_num_t) 2
 ^
<command-line>:0:0: note: this is the location of the previous definition
src\Blink.cpp:29:0: warning: "BUTTON_PIN_GPIO" redefined
 #define BUTTON_PIN_GPIO (gpio_num_t) 0
 ^
<command-line>:0:0: note: this is the location of the previous definition
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSCL.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Indexing .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-log.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c: In function 'spiTransferBytesNL':
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_out8 = &result[c_longs-1];
                                       ^
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_data8 = &last_data;
                                        ^
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
*** [.pio\build\esp32doit-devkit-v1\firmware.elf] Implicit dependency `C:\Users\HADOUNE\.platformio\platforms\espressif32\builder\=' not found, needed by target `.pio\build\esp32doit-devkit-v1\firmware.elf'.
======================================================== [FAILED] Took 17.34 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.

You can either put the #define BUTTON_PIN_GPIO in the code or define it externally via build_flags, but not both at the same time.

Remove the spaces arround the = sign in -D BUTTON_PIN_GPIO = 0.

the error persists…

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
Compiling .pio\build\esp32doit-devkit-v1\src\Blink.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-log.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c: In function 'spiTransferBytesNL':
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_out8 = &result[c_longs-1];
                                       ^
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_data8 = &last_data;
                                        ^
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
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 16.93 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.

> 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.73 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.

No it’s a different error.

You are programming against framework = arduino, hence the framework needs you to implement setup() and loop(). You are however not implementing that, only app_main() (which also needs a extern "C" declaration in front of it if implemented in a .cpp file, I am pretty sure), as if it were pure ESP-IDF.

You may want to refactor app_main() into setup() and create an empty loop() function if you want to write ESP-IDF code within an Arduino framework context (and use delay() to feed the watchdog), or follow the example

closely with its cmake files and framework = arduino, espidf choice.

the error persists…

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...
Dependency Graph
|-- <SCServo-master> 0.0.0+20210817123422
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\Blink.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSCL.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SCSerail.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSBL.cpp.o
src\Blink.cpp:28:0: warning: "LED_PIN_GPIO" redefined
 #define LED_PIN_GPIO (gpio_num_t) 2
 ^
<command-line>:0:0: note: this is the location of the previous definition
src\Blink.cpp:29:0: warning: "BUTTON_PIN_GPIO" redefined
 #define BUTTON_PIN_GPIO (gpio_num_t) 1
 ^
<command-line>:0:0: note: this is the location of the previous definition
Compiling .pio\build\esp32doit-devkit-v1\libfb7\SCServo-master\SMSCL.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Indexing .pio\build\esp32doit-devkit-v1\libfb7\libSCServo-master.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-log.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c: In function 'spiTransferBytesNL':
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_out8 = &result[c_longs-1];
                                       ^
C:\Users\HADOUNE\.platformio\packages\framework-arduinoespressif32\cores\esp32\esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
                 uint8_t * last_data8 = &last_data;
                                        ^
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
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 19.19 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.

the file which is in the link you sent me doesn’t read Arduino.h library!
here is a screen for the error!
image
I took the same example!!
image
Cmake file:

idf_component_register(SRCS "Blink.cpp")

2nd cmake file :

cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(espidf-arduino-wifiscan)

I can’t understand where the problem is ?

here is the error i am getting if i use the file you sent me :

> Executing task in folder espidf-arduino-blink: C:\Users\HADOUNE\.platformio\penv\Scripts\platformio.exe run <

[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\.cmake\\api\\v1\\reply\\target-__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd-67c7174e98bbab7e239b.json'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\.cmake\api\v1\reply\target-__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd-67c7174e98bbab7e239b.json`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\.cmake\\api\\v1\\reply'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\.cmake\api\v1\reply`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\.cmake\\api\\v1'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\.cmake\api\v1`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\.cmake\\api'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\.cmake\api`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\.cmake'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\.cmake`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\BluetoothSerial'  
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\BluetoothSerial`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\BluetoothSerial'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\BluetoothSerial`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\WebServer\\src'   
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\WebServer\src`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\WebServer\\src'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\WebServer\src`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\WebServer'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\WebServer`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\WiFiClientSecure' 
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\WiFiClientSecure`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries\\WiFiClientSecure'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries\WiFiClientSecure`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir\\libraries'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir\libraries`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles\\__idf_framework-arduinoespressif32.dir'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles\__idf_framework-arduinoespressif32.dir`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32\\CMakeFiles'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32\CMakeFiles`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\\CMakeFiles\\__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd.dir'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\CMakeFiles\__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd.dir`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\\CMakeFiles\\__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd.dir'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\CMakeFiles\__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd.dir`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\\CMakeFiles'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd\CMakeFiles`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\libsodium\\CMakeFiles\\__idf_libsodium.dir\\libsodium\\src\\libsodium\\crypto_box\\curve25519xchacha20poly1305'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\libsodium\CMakeFiles\__idf_libsodium.dir\libsodium\src\libsodium\crypto_box\curve25519xchacha20poly1305`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\libsodium\\CMakeFiles\\__idf_libsodium.dir\\libsodium\\src\\libsodium\\crypto_box\\curve25519xsalsa20poly1305' 
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\libsodium\CMakeFiles\__idf_libsodium.dir\libsodium\src\libsodium\crypto_box\curve25519xsalsa20poly1305`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\libsodium\\CMakeFiles\\__idf_libsodium.dir\\libsodium\\src\\libsodium\\crypto_pwhash\\scryptsalsa208sha256\\nosse'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\libsodium\CMakeFiles\__idf_libsodium.dir\libsodium\src\libsodium\crypto_pwhash\scryptsalsa208sha256\nosse`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\libsodium\\CMakeFiles\\__idf_libsodium.dir\\libsodium\\src\\libsodium\\crypto_pwhash\\scryptsalsa208sha256\\sse'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\libsodium\CMakeFiles\__idf_libsodium.dir\libsodium\src\libsodium\crypto_pwhash\scryptsalsa208sha256\sse`
[WinError 3] Le chemin d’accès spécifié est introuvable: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf\\libsodium\\CMakeFiles\\__idf_libsodium.dir\\libsodium\\src\\libsodium\\crypto_scalarmult\\curve25519\\donna_c64'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf\libsodium\CMakeFiles\__idf_libsodium.dir\libsodium\src\libsodium\crypto_scalarmult\curve25519\donna_c64`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev\\esp-idf'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev\esp-idf`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build\\esp32dev'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build\esp32dev`
[WinError 145] Le répertoire n’est pas vide: 'C:\\Users\\HADOUNE\\Downloads\\Compressed\\platform-espressif32-develop\\platform-espressif32-develop\\examples\\espidf-arduino-blink\\.pio\\build'
Please manually remove the file `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build`
Can not remove temporary directory `C:\Users\HADOUNE\Downloads\Compressed\platform-espressif32-develop\platform-espressif32-develop\examples\espidf-arduino-blink\.pio\build`. Please remove it manually to avoid build issues
Processing esp32dev (board: esp32dev; platform: espressif32; framework: arduino, espidf)
------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.3.1) > Espressif ESP32 Dev Module
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 0.0.0+sha.d011dd7
 - framework-espidf 3.40001.200521 (4.0.1)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30100.210531 (3.1.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
WARNING: You are using pip version 21.2.2; however, version 21.2.4 is available.
You should consider upgrading via the 'C:\Users\HADOUNE\.platformio\penv\Scripts\python.exe -m pip install --upgrade pip' command.
Warning! Arduino framework as an ESP-IDF component doesn't handle the `variant` field! The default `esp32` variant will be used.
Reading CMake configuration...
Error: Couldn't find target config target-__idf_framework-arduinoespressif32-src-a8a830ef46fb935b080bfdf62a3092dd-23db4d60c3ed05cd5b68.json
=========================== [FAILED] Took 12.57 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.