I add some functions in the mbedtls and try to compile it to static library, but the gcc always uses the offical mbedtls library in the .platformio directory, as shown below(libsmbedtls is the library I want to use):
xtensa-esp32-elf-g++ -o .pio\build\lolin32\firmware.elf -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -Wl,--wrap=mbedtls_mpi_exp_mod -Wl,--wrap=longjmp -Wl,--undefined=uxTopUsedPriority -T esp32.rom.redefined.ld -T memory.ld -T sections.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.peripherals.ld -u ld_include_hli_vectors_bt -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u ld_include_highint_hdl -u start_app -u start_app_other_cores -u __ubsan_include -u __assert_func -u vfs_include_syscalls_impl -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -Wl,-Map="D:\Projectdir\.pio\build\lolin32\firmware.map" .pio\build\lolin32\src\main.cpp.o -L.pio\build\lolin32 -LC:\Users\xxx\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib -LC:\Users\xxx\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\ld -Wl,--start-group .pio\build\lolin32\lib591\libBluetoothSerial.a .pio\build\lolin32\libe30\libsmbedtls.a .pio\build\lolin32\libbe2\libWiFi.a .pio\build\lolin32\libFrameworkArduinoVariant.a .pio\build\lolin32\libFrameworkArduino.a -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls(<---HERE) ......
And then ld will return with error:
/Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/mbedtls/mbedtls/library/md5.c:444: multiple definition of `mbedtls_md5'; .pio\build\lolin32\libe30\libsmbedtls.a(md5.c.o):D:\Projectdir/lib/smbedtls/src/md5.c:320: first defined here
It seems that my own mbedtls library has the same functions and the confict happened. But I don’t know if mbedtls is any other libraries’ dependency. So I want to know if there is any simple solution to this condition. Thanks!
file structure:
|--lib
| |
| |--smbedtls
| | |--src
| | |- md5.c
| | |--mbedtls
| | |- md5.h
| | |- ...
| |
| |- README
|
|- platformio.ini
|--src
|- main.c