openfl / openfl

The Open Flash Library for creative expression on the web, desktop, mobile and consoles.
http://www.openfl.org
MIT License
1.91k stars 433 forks source link

Error LNK2019: unresolved external symbol on SSL.obj when trying to build statically linked exe #2603

Open Dimous opened 1 year ago

Dimous commented 1 year ago

Hello! Subj ^

Describe the bug In the end of compilation process I get:

Link: libApplicationMain.lib
Link: Main.exe
Creating library Main.lib and object Main.exp
libApplicationMain.lib(849b6c05_SSL.obj) : error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function "class Dynamic __cdecl _hx_ssl_cert_load_defaults(void)" (?_hx_ssl_cert_load_defaults@@YA?AVDynamic@@XZ).
libApplicationMain.lib(849b6c05_SSL.obj) : error LNK2019: unresolved external symbol __imp_CertEnumCertificatesInStore referenced in function "class Dynamic __cdecl _hx_ssl_cert_load_defaults(void)" (?_hx_ssl_cert_load_defaults@@YA?AVDynamic@@XZ).
libApplicationMain.lib(849b6c05_SSL.obj) : error LNK2019: unresolved external symbol __imp_CertOpenSystemStoreA referenced in function "class Dynamic __cdecl _hx_ssl_cert_load_defaults(void)" (?_hx_ssl_cert_load_defaults@@YA?AVDynamic@@XZ).
Main.exe : fatal error LNK1120: unresolved externals: 3

To Reproduce Steps to reproduce the behavior:

  1. install git versions of hxcpp, lime, openfl
  2. run lime rebuild windows -static
  3. run openfl test windows -final -release -static -dce full -D no-debug -D no-traces -D nocppiaast -D analyzer-optimize
  4. See error

Expected behavior To build standalone exe

OpenFL Targets Windows 10 x64

Additional context I use visual studio community 2022

zanzlanz commented 2 months ago

Hey! Old post, I know, but in case someone else finds this via search, I wanted to document the workaround.

This is a persistent issue relating to hxcpp, which is currently documented here: https://github.com/HaxeFoundation/hxcpp/issues/777

The current workaround is to find the \src\hx\libs\ssl\Build.xml file inside of your current hxcpp library directory, and change a line near the bottom. Change it from: <lib name="crypt32.lib" if="windows" unless="static_link" /> to: <lib name="crypt32.lib" if="windows" />

After running lime rebuild windows -static, you should now be able to build your project without the linker errors.

tobil4sk commented 2 months ago

The correct fix might be to add this library here instead: https://github.com/openfl/lime/blob/95baa58effaff3f6158d642873dd329a8f6e048a/templates/cpp/static/BuildMain.xml#L37