EC200U-CN: Using mbedtls in the app

Hi All,

I’m using mbedtls (that is already integrated in the sdk). Added the following line to the app’s CMakeLists.txt
target_link_libraries(${target} mbedtls). But getting linker error:

lib/libmbedtls.a(pk.c.obj): In function mbedtls_pk_init': e:\Projects\Quectel\EC200UCNAAR02A06M08_OCPU_CSDK\out\8915DM_cat1_open_release/../../components/net/mbedtls/library/pk.c:52: multiple definition of mbedtls_pk_init’
lib/core_stub.o:(.text.core_stub.mbedtls_pk_init+0x0): first defined here
lib/libmbedtls.a(pk.c.obj): In function mbedtls_pk_free': e:\Projects\Quectel\EC200UCNAAR02A06M08_OCPU_CSDK\out\8915DM_cat1_open_release/../../components/net/mbedtls/library/pk.c:63: multiple definition of mbedtls_pk_free’
lib/core_stub.o:(.text.core_stub.mbedtls_pk_free+0x0): first defined here
lib/libmbedtls.a(timing.c.obj): In function mbedtls_timing_set_delay': e:\Projects\Quectel\EC200UCNAAR02A06M08_OCPU_CSDK\out\8915DM_cat1_open_release/../../components/net/mbedtls/library/timing.c:346: multiple definition of mbedtls_timing_set_delay’
lib/core_stub.o:(.text.core_stub.mbedtls_timing_set_delay+0x0): first defined here
lib/libmbedtls.a(timing.c.obj): In function mbedtls_timing_get_delay': e:\Projects\Quectel\EC200UCNAAR02A06M08_OCPU_CSDK\out\8915DM_cat1_open_release/../../components/net/mbedtls/library/timing.c:356: multiple definition of mbedtls_timing_get_delay’
lib/core_stub.o:(.text.core_stub.mbedtls_timing_get_delay+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Please let me know how to solve this issue.

Thanks,
Prakash

Hi Prakash
You can refer to the documentation to solve your problem.
Quectel_EC200U_Series_QuecOpen_CSDK_Quick_Start_Guide_V1.0.0_Preliminary_20211209.pdf (1.1 MB)

Hi Felix,

I’m already following the document you shared. The application compiles fine with out mbedtls. I get linker error only if call mbedtls functions and add target_link_libraries(${target} mbedtls) to the CMakeLists.txt
Even though many functions are there in mbedtls, I get linker error for only 4 of them: mbedtls_pk_init, mbedtls_pk_free, mbedtls_timing_set_delay, and mbedtls_timing_get_delay. It has something to do with core_stub.o. We’re stuck in this issue for a long time. It will be good if there is an mbedtls sample app.

Thanks,
Prakash