How to add a new external library?

HDne23
Posts: 7
Joined: Mon Aug 09, 2021 9:49 am

How to add a new external library?

Postby HDne23 » Mon Aug 09, 2021 10:02 am

Hi,
I've a library that works with arduino and it was written in c++ (header & cpp files), I added the library files to my esp idf extension with no errors, when i try to build my project, here what I got:

Code: Select all

Executing task in folder SCServo-master: cmake -G Ninja .. <

-- Found Git: C:/Users/HADOUNE/.espressif/tools/idf-git/2.30.1/cmd/git.exe (found version "2.30.1.windows.1")
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/HADOUNE/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/HADOUNE/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/HADOUNE/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features       
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Users/HADOUNE/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/Users/HADOUNE/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32
-- Checking Python dependencies...
Python requirements from C:\Users\HADOUNE\esp\esp-idf\requirements.txt are satisfied.
-- Project sdkconfig file C:/Users/HADOUNE/Downloads/Compressed/SCServo-master/SCServo-master/sdkconfig
-- Found PythonInterp: C:/Users/HADOUNE/.espressif/python_env/idf4.3_py3.8_env/Scripts/python.exe (found version "3.8.7")
-- Could NOT find Perl (missing: PERL_EXECUTABLE) 
CMake Warning (dev) at C:/Users/HADOUNE/esp/esp-idf/components/mbedtls/CMakeLists.txt:114 (target_sources):
  Policy CMP0076 is not set: target_sources() command converts relative paths
  to absolute.  Run "cmake --help-policy CMP0076" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  A private source from a directory other than that of target "mbedcrypto"
  has a relative path.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- App "ReadPos" version: 1
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script C:/Users/HADOUNE/Downloads/Compressed/SCServo-master/SCServo-master/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script C:/Users/HADOUNE/esp/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Components: app_trace app_update asio bootloader bootloader_support bt cbor cmock coap console cxx driver efuse esp-tls esp32 esp_adc_cal esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_ipc esp_local_ctrl esp_netif esp_pm esp_ringbuf esp_rom esp_serial_slave_link esp_system esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos hal heap idf_test jsmn json libsodium log lwip mbedtls mdns mqtt newlib nghttp nvs_flash openssl partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport tcpip_adapter tinyusb ulp unity vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: C:/Users/HADOUNE/esp/esp-idf/components/app_trace C:/Users/HADOUNE/esp/esp-idf/components/app_update C:/Users/HADOUNE/esp/esp-idf/components/asio C:/Users/HADOUNE/esp/esp-idf/components/bootloader C:/Users/HADOUNE/esp/esp-idf/components/bootloader_support C:/Users/HADOUNE/esp/esp-idf/components/bt C:/Users/HADOUNE/esp/esp-idf/components/cbor C:/Users/HADOUNE/esp/esp-idf/components/cmock C:/Users/HADOUNE/esp/esp-idf/components/coap C:/Users/HADOUNE/esp/esp-idf/components/console C:/Users/HADOUNE/esp/esp-idf/components/cxx C:/Users/HADOUNE/esp/esp-idf/components/driver C:/Users/HADOUNE/esp/esp-idf/components/efuse C:/Users/HADOUNE/esp/esp-idf/components/esp-tls C:/Users/HADOUNE/esp/esp-idf/components/esp32 C:/Users/HADOUNE/esp/esp-idf/components/esp_adc_cal C:/Users/HADOUNE/esp/esp-idf/components/esp_common C:/Users/HADOUNE/esp/esp-idf/components/esp_eth C:/Users/HADOUNE/esp/esp-idf/components/esp_event C:/Users/HADOUNE/esp/esp-idf/components/esp_gdbstub C:/Users/HADOUNE/esp/esp-idf/components/esp_hid C:/Users/HADOUNE/esp/esp-idf/components/esp_http_client C:/Users/HADOUNE/esp/esp-idf/components/esp_http_server C:/Users/HADOUNE/esp/esp-idf/components/esp_https_ota C:/Users/HADOUNE/esp/esp-idf/components/esp_https_server C:/Users/HADOUNE/esp/esp-idf/components/esp_hw_support C:/Users/HADOUNE/esp/esp-idf/components/esp_ipc C:/Users/HADOUNE/esp/esp-idf/components/esp_local_ctrl C:/Users/HADOUNE/esp/esp-idf/components/esp_netif C:/Users/HADOUNE/esp/esp-idf/components/esp_pm C:/Users/HADOUNE/esp/esp-idf/components/esp_ringbuf C:/Users/HADOUNE/esp/esp-idf/components/esp_rom C:/Users/HADOUNE/esp/esp-idf/components/esp_serial_slave_link C:/Users/HADOUNE/esp/esp-idf/components/esp_system C:/Users/HADOUNE/esp/esp-idf/components/esp_timer C:/Users/HADOUNE/esp/esp-idf/components/esp_websocket_client C:/Users/HADOUNE/esp/esp-idf/components/esp_wifi C:/Users/HADOUNE/esp/esp-idf/components/espcoredump C:/Users/HADOUNE/esp/esp-idf/components/esptool_py C:/Users/HADOUNE/esp/esp-idf/components/expat C:/Users/HADOUNE/esp/esp-idf/components/fatfs C:/Users/HADOUNE/esp/esp-idf/components/freemodbus C:/Users/HADOUNE/esp/esp-idf/components/freertos C:/Users/HADOUNE/esp/esp-idf/components/hal C:/Users/HADOUNE/esp/esp-idf/components/heap C:/Users/HADOUNE/esp/esp-idf/components/idf_test C:/Users/HADOUNE/esp/esp-idf/components/jsmn C:/Users/HADOUNE/esp/esp-idf/components/json C:/Users/HADOUNE/esp/esp-idf/components/libsodium C:/Users/HADOUNE/esp/esp-idf/components/log C:/Users/HADOUNE/esp/esp-idf/components/lwip C:/Users/HADOUNE/esp/esp-idf/components/mbedtls C:/Users/HADOUNE/esp/esp-idf/components/mdns C:/Users/HADOUNE/esp/esp-idf/components/mqtt C:/Users/HADOUNE/esp/esp-idf/components/newlib C:/Users/HADOUNE/esp/esp-idf/components/nghttp C:/Users/HADOUNE/esp/esp-idf/components/nvs_flash C:/Users/HADOUNE/esp/esp-idf/components/openssl C:/Users/HADOUNE/esp/esp-idf/components/partition_table C:/Users/HADOUNE/esp/esp-idf/components/perfmon C:/Users/HADOUNE/esp/esp-idf/components/protobuf-c C:/Users/HADOUNE/esp/esp-idf/components/protocomm C:/Users/HADOUNE/esp/esp-idf/components/pthread C:/Users/HADOUNE/esp/esp-idf/components/sdmmc C:/Users/HADOUNE/esp/esp-idf/components/soc C:/Users/HADOUNE/esp/esp-idf/components/spi_flash C:/Users/HADOUNE/esp/esp-idf/components/spiffs C:/Users/HADOUNE/esp/esp-idf/components/tcp_transport C:/Users/HADOUNE/esp/esp-idf/components/tcpip_adapter C:/Users/HADOUNE/esp/esp-idf/components/tinyusb C:/Users/HADOUNE/esp/esp-idf/components/ulp C:/Users/HADOUNE/esp/esp-idf/components/unity C:/Users/HADOUNE/esp/esp-idf/components/vfs C:/Users/HADOUNE/esp/esp-idf/components/wear_levelling C:/Users/HADOUNE/esp/esp-idf/components/wifi_provisioning C:/Users/HADOUNE/esp/esp-idf/components/wpa_supplicant C:/Users/HADOUNE/esp/esp-idf/components/xtensa      
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/HADOUNE/Downloads/Compressed/SCServo-master/SCServo-master/build

Terminal will be reused by tasks, press any key to close it.
the buidling project notification keeps turning on with no response for more than one hour!
can you please tell me how to solve this problem ?
Thank you

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: How to add a new external library?

Postby mbratch » Tue Aug 10, 2021 10:39 am

I added the library files to my esp idf extension with no errors
Extension to what? What IDE are you using for your build? How did you add the library files? When you say there were no errors adding the files, does that mean no errors in compiling the files or something else?

User avatar
fasani
Posts: 196
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: How to add a new external library?

Postby fasani » Tue Aug 10, 2021 11:37 am

Hello HDNe,

In order to do that is very good idea to understand at least to some extent the Build system. And also how CMakeFiles works.
For example in my epaper component you can see how is using the components:
https://github.com/martinberlin/cale-idf

In that version the components are in the repository so it's faster to develop. But ideally the components in IDF are added using git-submodules like you can see in many other projects.
Note also that not all the Arduino-ESP32 code can be used directly on Espressif IDF without modifications.

Notice that also if you use CPP classes you need to use in your main cpp:

Code: Select all

extern "C"
{
   void app_main();
}
As an example check here.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

HDne23
Posts: 7
Joined: Mon Aug 09, 2021 9:49 am

Re: How to add a new external library?

Postby HDne23 » Tue Aug 10, 2021 12:34 pm

mbratch wrote:
Tue Aug 10, 2021 10:39 am
I added the library files to my esp idf extension with no errors
Extension to what? What IDE are you using for your build? How did you add the library files? When you say there were no errors adding the files, does that mean no errors in compiling the files or something else?
Hi,
I meant by no errors that the Vs code compiler recognized the added libraries (without any line below the added libraries), Actually, the system now started building and it stops at 985/990 with this error :

Code: Select all


 -c ../main/ReadPos.c
../main/ReadPos.c:10:10: fatal error: SCServo.h: No such file or directory
 #include <SCServo.h>
          ^~~~~~~~~~~
compilation terminated.
[985/990] Linking C static library esp-idf\wifi_provisioning\libwifi_provisioning.a
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\cmd.exe /d /c cmake --build ." terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

this is an external c++ library that i've used to use it in Arduino IDE which works perfectly, I wanted to use it with VS code IDF espressif extension but in vain....

HDne23
Posts: 7
Joined: Mon Aug 09, 2021 9:49 am

Re: How to add a new external library?

Postby HDne23 » Tue Aug 10, 2021 12:41 pm

fasani wrote:
Tue Aug 10, 2021 11:37 am
Hello HDNe,

In order to do that is very good idea to understand at least to some extent the Build system. And also how CMakeFiles works.
For example in my epaper component you can see how is using the components:
https://github.com/martinberlin/cale-idf

In that version the components are in the repository so it's faster to develop. But ideally the components in IDF are added using git-submodules like you can see in many other projects.
Note also that not all the Arduino-ESP32 code can be used directly on Espressif IDF without modifications.

Notice that also if you use CPP classes you need to use in your main cpp:

Code: Select all

extern "C"
{
   void app_main();
}

Thank you for replying,
Here is the error i am getting when i try to build the code

Code: Select all

 -c ../main/ReadPos.c
../main/ReadPos.c:10:10: fatal error: SCServo.h: No such file or directory
 #include <SCServo.h>
          ^~~~~~~~~~~
compilation terminated.
[985/990] Linking C static library esp-idf\wifi_provisioning\libwifi_provisioning.a
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\cmd.exe /d /c cmake --build ." terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

This is an external library that i've used to use on arduino IDE without problems, the problems comes when i tried to use it in VS code with IDF espressif library, Actually other projects like Blink... works perfectly...
The external library has several .h header files and cpp files.
here is my Top Cmakelist.txt file :

Code: Select all


# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ReadPos)


and here is the main code cmakelist file

Code: Select all

idf_component_register(SRCS "ReadPos.c"
                    INCLUDE_DIRS ".")
I hope that it is clear.
Thank you for your help!

User avatar
fasani
Posts: 196
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: How to add a new external library?

Postby fasani » Tue Aug 10, 2021 9:47 pm

Please read the Build documentation and try to understand the examples I referenced.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

HDne23
Posts: 7
Joined: Mon Aug 09, 2021 9:49 am

Re: How to add a new external library?

Postby HDne23 » Tue Aug 10, 2021 10:07 pm

fasani wrote:
Tue Aug 10, 2021 9:47 pm
Please read the Build documentation and try to understand the examples I referenced.
I think that this is not what i am looking for... you sent me a link which is talking about touch screen panel library... while I am trying to include an external servo moto library into Vs code (IDF ESP...)…Etc.

User avatar
fasani
Posts: 196
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: How to add a new external library?

Postby fasani » Sat Aug 14, 2021 10:29 pm

HDne23 wrote:
Tue Aug 10, 2021 10:07 pm
I think that this is not what i am looking for... you sent me a link which is talking about touch screen panel library... while I am trying to include an external servo moto library into Vs code (IDF ESP...)…Etc.
What I mean is that looking at any other example, mine was just a reference, you can get a grasp of how is done. And I think is very important to understand how is the build process. I understand that at the beginning can be a bit frustrating to get the things working but once you understand the build process and look at some already working examples, everything becomes easier.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

HDne23
Posts: 7
Joined: Mon Aug 09, 2021 9:49 am

Re: How to add a new external library?

Postby HDne23 » Tue Aug 17, 2021 8:59 pm

fasani wrote:
Sat Aug 14, 2021 10:29 pm
HDne23 wrote:
Tue Aug 10, 2021 10:07 pm
I think that this is not what i am looking for... you sent me a link which is talking about touch screen panel library... while I am trying to include an external servo moto library into Vs code (IDF ESP...)…Etc.
What I mean is that looking at any other example, mine was just a reference, you can get a grasp of how is done. And I think is very important to understand how is the build process. I understand that at the beginning can be a bit frustrating to get the things working but once you understand the build process and look at some already working examples, everything becomes easier.
Actually, the problem is not with the build process anymore, the problem is that i am trying to include an arduino library to an idf espressif doc, i am gettin error like WProgram.h: No such file or directory, WProgram.h is an internal arduino stuff, while IDF espressif can't read it! it's been more than 20 days since i started looking for a solution! but in vain...

User avatar
fasani
Posts: 196
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: How to add a new external library?

Postby fasani » Wed Aug 18, 2021 9:33 am

Check this documentation:
https://docs.espressif.com/projects/ard ... onent.html

I also had errors when I tried to use Arduino as a component and I had to go and comments some libraries out (That I don't use anyways). I did that since I was trying to compile some example from an external source.
But I don't like to do that. The best way is to use ESP-IDF directly or Arduino-esp32 but not to mix them together.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

Who is online

Users browsing this forum: No registered users and 108 guests