Skip to content

Conflicts when static linking a library that uses mbedtls #1126

@tobil4sk

Description

@tobil4sk

In static builds of lime projects, lime's mbedtls conflicts with hxcpp's (more info at openfl/lime#1767). This will be a problem especially with the mbedtls 3 upgrade (#1113).

I'm not sure if this might be the same issue as #777, because that talks about including .lib files.

There are two possible solutions I can think of.

Solution 1: Hxcpp uses lime's mbedtls

  • hxcpp supports compiling against multiple versions of mbedtls with conditional compilation, we add HXCPP_LINK_NO_MBEDTLS. We would also need to add a flag to set the include path of mbedtls (e.g. HXCPP_MBEDTLS_INCLUDE_DIR). Maybe we'd also need to allow passing in a custom MBEDTLS_USER_CONFIG_FILE path?
  • This is similar to how hxcpp libz linking problems #313 was resolved.
  • This is the simpler solution, but I'm worried about if there will be any issues with hxcpp's mbedtls threading config potentially missing? It was added in e5003a3 and it seems important.

Solution 2: Lime uses hxcpp's mbedtls

  • Expose the flags and files required for building hxcpp's mbedtls (without SSL.cpp). Lime can then be built against hxcpp's mbedtls, but not link it in the lime static library. Then, depending on whether hxcpp is built with ssl or not (hxcpp would have to provide some way to check this) *, lime has manually include hxcpp's mbedtls when finally linking the project.
  • This is more complicated but means that hxcpp uses its own version (with its threading config) and doesn't need to support multiple versions of mbedtls.

@hughsando I was wondering if you have any thoughts?

* EDIT: there is no need for this, as including the same sources twice doesn't seem to cause issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions