creating custom library

mfawzy79
Posts: 4
Joined: Thu Feb 18, 2021 11:21 pm

creating custom library

Postby mfawzy79 » Thu Feb 18, 2021 11:31 pm

Hello All,

I'm trying to create custom library .a (UART-test project)and the project is compiled and generated the .a and another project (ExternalImport) which is importing the .a.
the issue that the ExternalImport can't find a reference to the functions that are implemented in the .a

So what is wrong with the generated library?

Another question, what if I need to include a library from the ESP-IDF like spi_flash, is it possible? and if possible, what are the needed commands to be added to my CMake files?
cmaketest.zip
(20.42 KiB) Downloaded 134 times
Thanks in advance.
Mohammed

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

Re: creating custom library

Postby chegewara » Fri Feb 19, 2021 1:19 am

Did you include header files from UART .a in ExternalImport project?

mfawzy79
Posts: 4
Joined: Thu Feb 18, 2021 11:21 pm

Re: creating custom library

Postby mfawzy79 » Sat Feb 20, 2021 12:03 pm

yes, I did. I'm only getting the below library.


cmd.exe /C "cd . && C:\Users\mfawz\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\import_prebuilt.elf.rsp -o import_prebuilt.elf && cd ."
c:/users/mfawz/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj):(.literal.app_main+0x0): undefined reference to `prebuilt_func'
c:/users/mfawz/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj):(.literal.app_main+0x4): undefined reference to `test'
c:/users/mfawz/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj): in function `app_main':
d:\cmaketest\externalimport\build/../main/main.c:17: undefined reference to `prebuilt_func'
c:/users/mfawz/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: d:\cmaketest\externalimport\build/../main/main.c:18: undefined reference to `test'

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

Re: creating custom library

Postby chegewara » Sat Feb 20, 2021 10:11 pm

With properly setup paths i get this (only part of logs):

Code: Select all

/home/chegewara/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/chegewara/demos/esp32s2/forks/UART-test/build/prebuilt/libprebuilt.a: error adding symbols: file format not recognized
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Another thing is, that in your UART-test project you did not use test and prebuild_func, so they are not linked in library. You need at least minimal code like this:

Code: Select all

void app_main(void)
{
    test();
    prebuilt_func();
}
at least i had to do this, when i built static library for esp32, but my static library also was built using esp32 toolchain.

mfawzy79
Posts: 4
Joined: Thu Feb 18, 2021 11:21 pm

Re: creating custom library

Postby mfawzy79 » Sun Feb 21, 2021 1:48 pm

Can you please to send me the two projects (UART_test, ExternalImport) in a zip file after update.

Who is online

Users browsing this forum: Google [Bot] and 54 guests