linker problem using mbedtls component

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

linker problem using mbedtls component

Postby mzimmers » Mon Aug 15, 2022 11:37 pm

Hi all -

I'm porting a program to the ESP32. I just enabled the portion of code that uses md5 (it supplies its own files for this) and now I can't link. When I try to use the files in my project folder, this code passage:

Code: Select all

    mbedtls_md5_init(&Zctx);
    mbedtls_md5_starts(&Zctx);
results in this error:

Code: Select all

	C:/Espressif/frameworks/esp-idf-v4.4.1/components/mbedtls/mbedtls/library/md5.c:391: multiple definition of `mbedtls_md5'; esp-idf/main/libmain.a(md5.c.obj):C:\repos\iQPump-ESP32\fw\build/../main/md5.c:322: first defined here
But when I remove the local copy of md5.c from my CMakeLists.txt file, I get this:

Code: Select all

	esp-idf/main/libmain.a(i2d_app.c.obj): in function `RS485_SendFirmwareBlocks':
	C:\repos\iQPump-ESP32\fw\build/../main/i2d_app.c:1399: undefined reference to `mbedtls_md5_starts'
Any ideas what's going on?

EDIT: The reason I included the line mbedtls_md5_init(&Zctx); above is to show that *some* of the functions in the file seem to be found. I tried a few others and they worked; there's just something about mbedtls_md5_starts().

ESP_Mahavir
Posts: 188
Joined: Wed Jan 24, 2018 6:51 am

Re: linker problem using mbedtls component

Postby ESP_Mahavir » Thu Aug 18, 2022 7:13 am

I think you can simply rename instance of `mbedtls_md5_starts` to `mbedtls_md5_starts_ret`, it should fix the problem.

Former API is deprecated and we have not kept any mapping in our `components/mbedtls/port/include/md5_alt.h` (ROM implementation) file.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: linker problem using mbedtls component

Postby mzimmers » Thu Aug 18, 2022 3:48 pm

Hi ESP_Mahavir -

This does eliminate the compile time errors. It appears, however, that I'm using a routine found in the openthread component, instead of the mbedtls component:
md5.PNG
md5.PNG (50.09 KiB) Viewed 2337 times
Am I correctly interpreting this window?

Thanks...

ESP_Mahavir
Posts: 188
Joined: Wed Jan 24, 2018 6:51 am

Re: linker problem using mbedtls component

Postby ESP_Mahavir » Fri Aug 19, 2022 2:46 am

No, we do not use `mbedtls` from openthread. This can be confirmed from its build template `components/openthread/CMakeLists.txt`.

I would recommend that you refer to "<project>.map" file generated in your projects build directory to understand how a particular symbol is resolved and from where. That shall help here.

Who is online

Users browsing this forum: hp_song, leschge and 130 guests