hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

hxcpp, ssl and Mbedtl

Open ianharrigan opened this issue 5 years ago • 7 comments

I stumbled upon a Mbedtl dependency in hxcpp with regard to SSL inside hxcpp.

A little background: I know a friend who is trying to use haxeui as a static .lib via hxcpp, all works for the most part except there are references to ssl which dont play nice. Thanks to @Gama11 i could drill down and find out its based on sockets / http (which haxeui's ImageLoader uses). All fine.

My question is would it be advantageous to be able to #if ssl out of the picture (opt in to remove) if you didnt want to hit this dependency. Another option, ofc, would be to make Mbedtl work correctly statically, but it seems that an ability to "opt out" of any third party libs seems advantageous here (and in general).

Wondering what the thoughts are on this?

Cheers, Ian

ianharrigan avatar Apr 02 '19 21:04 ianharrigan

(addendum: i could #if out all of the remote image loading, but it seems drastic, http is fine, https is the issue wrt to the dependency)

ianharrigan avatar Apr 02 '19 21:04 ianharrigan

What are the issues? Both solutions (fix linking, avoid linking) are possible - eg, we have HXCPP_LINK_NO_ZLIB, but here we would be expecting an external implementation of zlib.

hughsando avatar Apr 04 '19 14:04 hughsando

Howdy. I'm the friend @ianharrigan mentioned. I ended up band-aiding things for now on my end by modifying hxcpp\4,0,8\src\hx\libs\ssl\Build.xml so that the appropriate libs would be linked when building static. Is it possible the current way you guys have it is in error in using unless="static_link" for those libs? Here's my change for reference, just modifying the lib tags: `

<!--lib name="advapi32.lib" if="windows" unless="static_link" />
<lib name="crypt32.lib" if="windows" unless="static_link" />
<lib name="ws2_32.lib" if="windows" unless="static_link" /-->
<lib name="advapi32.lib" if="windows" />
<lib name="crypt32.lib" if="windows" />
<lib name="ws2_32.lib" if="windows" unless="static_link" />

<flag value="-framework" if="macos"/>
<flag value="Security" if="macos"/>

`

intoxopox avatar Apr 04 '19 17:04 intoxopox

Another option, ofc, would be to make Mbedtl work correctly statically

I'm currently using haxe->hxcpp->static_lib for an iOS project. And that lib is actively using HTTPS and it works fine. So, probably it is a platform specific issue?

posxposy avatar Apr 08 '19 08:04 posxposy

Correct me if im wrong, but are "fix linking" and "avoid linking" mutually exclusive? Shouldnt any 3rd party lib be optional?

ianharrigan avatar Apr 10 '19 21:04 ianharrigan

Are you building the hxcpp-gen code into a library (rather than exe/dll)? If this is the case, the windows libraries (ws2_32.lib etc) do not (can not) go in the lib, they must be added to the linking of the final exe, presumably by whatever system uses the hxcpp-gen library.

hughsando avatar Apr 11 '19 03:04 hughsando

For what it's worth, only the crypt32.lib tag needs unless="static_link" removed in my workaround now, apparently.

intoxopox avatar Dec 28 '20 20:12 intoxopox