Page 1 of 1

linker problem using mbedtls component

Posted: Mon Aug 15, 2022 11:37 pm
by mzimmers
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().

Re: linker problem using mbedtls component

Posted: Thu Aug 18, 2022 7:13 am
by ESP_Mahavir
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.

Re: linker problem using mbedtls component

Posted: Thu Aug 18, 2022 3:48 pm
by mzimmers
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 2787 times
Am I correctly interpreting this window?

Thanks...

Re: linker problem using mbedtls component

Posted: Fri Aug 19, 2022 2:46 am
by ESP_Mahavir
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.