Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker not able to find some libs on Windows 10 #32

Closed
adeel41 opened this issue Jul 22, 2020 · 24 comments · Fixed by #33
Closed

Linker not able to find some libs on Windows 10 #32

adeel41 opened this issue Jul 22, 2020 · 24 comments · Fixed by #33
Assignees

Comments

@adeel41
Copy link

adeel41 commented Jul 22, 2020

I was trying to write some trivial pony code which uses http_server. I was aware that I need to have ssl and crypto libraries which I copied into the same directory. I used the following command to compile it.

corral run -- ponyc -D openssl_1.1.x

But that just only generated an obj file. The following is the output from that command.

Writing .\pony-ssl-issue.obj
detecting Visual Studio via ""%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -prerelease -latest -products *" 
searching for D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\ .. \bin\HostX64\x64\link.exe and \bin\HostX64\x64\lib.exe
linker:  D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\link.exe
libtool: D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\lib.exe
libdir:  D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\lib\x64
Linking .\pony-ssl-issue.exe
cmd /C ""D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\link.exe" /DEBUG /NOLOGO /MACHINE:X64 /ignore:4099 /OUT:.\pony-ssl-issue.exe .\pony-ssl-issue.obj /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\lib\x64" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_valbytes" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_http_server" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_net_ssl" /LIBPATH:"D:\Coding\github\ponyc\build\release" /LIBPATH:"D:\Coding\github\ponyc\build\release\..\..\packages" "ssl".lib "crypto".lib  kernel32.lib msvcrt.lib Ws2_32.lib advapi32.lib vcruntime.lib legacy_stdio_definitions.lib dbghelp.lib ucrt.lib libponyrt.lib 
"

I had a look at net_ssl project and I think the problem is on these line. This will only work on mac and linux.

use "path:/usr/local/opt/libressl/lib" if osx
use "lib:ssl"
use "lib:crypto"

To make it work on windows this needs to be something like this

use "path:/usr/local/opt/libressl/lib" if osx
use "lib:ssl" if not windows
use "lib:crypto" if not windows
use "lib:libssl" if windows
use "lib:libcrypto" if windows

So I created a fork of http_server and net_ssl repos. Fixed the issue in net_ssl fork and then reference it in http_server fork. Then I updated the corral.json in my trivial pony project and I was able to generate an executable.

I am facing another issue now which I am not sure if it is related but I'll just explain it anyways.

Have a look at this pony code https://github.com/adeel41/pony-ssl-issue/blob/master/main.pony
This code does not output "Hello World" but if I remove the use http_server` line then it works and output "Hello World".

I am not sure if it is related to the my changes in net_ssl repo or if there is something needed to be looked in http_server repo

@SeanTAllen
Copy link
Member

It shouldn't need that to work on Windows. What you did there was turn off all the crypto libs for Windows. It should work across all platforms. The OSX specific line is to deal with HomeBrew having a special install location on macOS.

How did you install the crypto libs?

@kulibali any ideas?

@SeanTAllen
Copy link
Member

Without using your forks @adeel41, can you compile to project as you were and also include what the output in the directory before and after you run the corral command?

corral run -- ponyc -D openssl_1.1.x

If you are using libressl for windows, Libressl uses the openssl_0.9.x API, so I think you do not want the -D openssl_1.1.x.

@adeel41
Copy link
Author

adeel41 commented Jul 22, 2020

@SeanTAllen I don't have much experience with compiling libs on windows. So I downloaded OpenSSL 1.1.1h pre-compiled libs from https://kb.firedaemon.com/support/solutions/articles/4000121705 and copied the lib files from x64\lib folder. which are libcrypto.lib and libssl.lib. Then I copied these files along with main.pony file (see https://github.com/adeel41/pony-ssl-issue)

If I run corral run -- ponyc -D openssl_1.1.x -V 4 without using my forks then it only generated an obj file with following output

run: ponyc -D openssl_1.1.x -V 4
  exit: Exited(-1)
  out:
Program signature: 120C2BB09C129FF2E032928267DA7A7A224F2B30FA28EE7635A251A2620CE126EB11D7FE0D3587E956789876BE9FB68D3F80AEAADF62D11007C55E9F048E6B30

Group 0
Signature: B29F47D2A6D569749837AE7E32257FBE784EDC0C8519D64F9E458EE66251ECADFB1EDB7E669379B4A8B5FA4112C8D03F0DE2E47E03C8AC00FC7AE318737DCE6E
Members:
  builtin
Dependencies:

Group 1
Signature: 7B23573BA9A36DDCFA50103E232A9275C7E8DB80F1DB563DFC08A2E87B3EF3ECFA2423DC8228FDD20AF3029C7936FE980B011E4A8E49F2F123A765ACEC317DDB
Members:
  debug
Dependencies:
  builtin

Group 2
Signature: C369E324E06D094C0F3E6175C9717696DF77039B20DF7F45CB42F5E36CCDC9838CAB562F1AC8E060231347DA7DD830ADB03C16E1FB32F659039A040CFF48E2EE
Members:
  random
  ponytest
  time
  collections
Dependencies:
  builtin

Group 3
Signature: 7578226559E107F0951EC8C7F1074CC96BD05B106AEA7C3DCBE0D504B8E21D35770A4ACADAFA0FBE08A8EC6BD399096BAF5D86C96CD999587FFAE47F2F328DAB
Members:
  itertools
Dependencies:
  builtin
  ponytest
  time
  collections

Group 4
Signature: 428DA49E2B0EA4EBC7C170F416D7585CFE6BACBEE1092A70FE6BAD24CCD20F8AFAC97F4AEB3BE48DFE164CD90F5F27B443B0699666FDBE3541907C2A6EF8E881
Members:
  assert
Dependencies:
  builtin

Group 5
Signature: A1B8DA7F9DAF4FB9DB389CC43D038A2CE8492E1AF8CDBBA723D11E1A2B913E22316296E19A87041C53A756ADD682DFFDA0FAC67460C987E7DB79288EC2108794
Members:
  ponycheck
Dependencies:
  debug
  collections
  time
  builtin
  itertools
  random
  ponytest
  assert

Group 6
Signature: 96EE39744D00D902F5DC5AEFFF01746E11436EB6EB5C842E7AD29A9CFE15D51F5B99014FA1903D2006A69DC01D98A32B574107DDAF5BB4EBAAD6DA73D44A289E
Members:
  format
Dependencies:
  builtin
  ponytest
  collections

Group 7
Signature: CDB032E215551E46A42A71198CE27C113702D04AC4082EFFD769A810D39DE4551202BF579FFD1D59AA4290AC1B453159A9E68124E0E5D73DE634E02579221387
Members:
  persistent
Dependencies:
  collections
  time
  builtin
  random
  ponytest

Group 8
Signature: E2941451F1C83F232FB163F530D38290E44EE90B9EAC360CA938CAEE0FE3CE5891560F4A470D986A1EA3A9F697CC0E53E8AD1B9299568AF6C8459A019CABEF13
Members:
  valbytes
Dependencies:
  ponycheck
  debug
  collections
  builtin
  ponytest
  persistent

Group 9
Signature: BACABE072C88159AED7E2E649A0DAF2A1E89764C273D7BB20EE5C842DFC850E58240567EB3F2D7EBDE5F968BCD4A86B43A4240F4A49BB8781AB62E32BE92C4E4
Members:
  strings
Dependencies:
  ponytest
  builtin

Group 10
Signature: F724466D6E05D62C30944C155E17A9AF4A3F80C786453863A204FC30956F225D780D609B40EC6B0228B52440106345399EE65EB1DA8CC3FF23B13DDC15CC2804
Members:
  promises
Dependencies:
  ponytest
  time
  builtin

Group 11
Signature: 72E6DDEC622814648C9A3637F9FB95FCDFA61AA9E52E2A1B3017A21F62593DD064BDD188C415D7054E700C10314205E0ADB5E9ADCE7EE9DAAB7B2747B13451D1
Members:
  signals
Dependencies:
  ponytest
  builtin

Group 12
Signature: C2A04CDF96E77EFBE9E1CE9EAC3E1747C157BDE8601827AF0793BB6C0E68C9557011F665D6CFD320CE0F4B1FB5587C05CDE2659C9A4A1F2421131A07BCF5C4DF
Members:
  buffered
Dependencies:
  builtin
  ponytest
  collections

Group 13
Signature: C975C08FC98E1F2ABBAE9059EC2C6E90B0A788FA01A4791D3588B167359710792E369845593E269A440BA14BFE67B42603E17CE3B5972DE20E1C7C4C222BDCC2
Members:
  files
  term
  capsicum
Dependencies:
  collections
  time
  builtin
  strings
  random
  ponytest
  buffered
  promises
  signals

Group 14
Signature: F1E4BFA2F55B21EAC206BCCBE9A9451153C70A26DCA1F23200912874B0CA1FDB22A5369667F9B33F3D66B11EC0A095BBEEEB3964A204177113E0A04FD5EF0F28
Members:
  net
Dependencies:
  builtin
  ponytest
  files
  collections

Group 15
Signature: D62BFCC48B094F6B890F698778B4A311C5E42E99A7BE116CE50BEE3AE92991A1DB5821E4BD459DC4A0F821C86688D332F24C699588020F2AAFA9067D6904F267
Members:
  json
Dependencies:
  builtin
  ponytest
  format
  collections

Group 16
Signature: B2477E4A36E6034E94D66B92FB9BE9ADFA8EB6550AD120DD3B4393AB66722C3B7E9AF3DAB7E2E6E730E82C147BD9244039F45A12059053565F4E9D90BCA5E737
Members:
  net_ssl
Dependencies:
  collections
  net
  builtin
  itertools
  files
  ponytest

Group 17
Signature: A217BE00FE98A0EFCAA95062375CE4BA589FAF358A0A12EBF2767EC91260350CC9DCABF42E6106BB1FE7C5F515B1D412B64E5E4294D1BBDA5AFC293C55058EE6
Members:
  http_server
Dependencies:
  debug
  ponycheck
  format
  valbytes
  collections
  net
  time
  builtin
  itertools
  ponytest
  buffered
  json
  persistent
  net_ssl

Group 18
Signature: 0FC244CDF67C9975F541D2E0D601C61D833C4C20D3353B856EFCE4B865E5B671720E06A9FCC75B8ADDAC4E06802FE3B2B8E8CA8D51CBDADCD7EDD78869C21606
Members:
  pony-ssl-issue
Dependencies:
  http_server
  builtin

REACH
  3: $0$6, o
    vtable: 0
    $0$15
  20: U32, I
    vtable: 24
      6: val_op_and_II
      10: box_op_and_II
      7: val_shl_II
      1: box_shl_II
      0: box_usize_Z
      2: val_usize_Z
      4: val_ne_Ib
      9: box_ne_Ib
      23: box___digestof_
      5: box_eq_Ib
      8: val_eq_Ib
      3: val_create_II
  -1: Pointer_AsioEvent_val, o
    vtable: 13
      0: ref_create_o
      7: ref_is_null_b
      6: box_is_null_b
      4: tag_is_null_b
      12: val_is_null_b
  4: u2_String_val_Array_U8_val_val, o
    vtable: 10
      9: box_cpointer_Zo
      3: val_cpointer_Zo
      0: ref_cpointer_Zo
      5: ref_size_Z
      8: val_size_Z
      1: box_size_Z
    Array_U8_val
    String
  9: net_ssl__OpenSslInitLoadCryptoStrings, o
    vtable: 7
      0: val_apply_W
      6: val_create_o
  -1: Pointer_Pointer_U8_val_ref, o
    vtable: 13
      7: ref_is_null_b
      6: box_is_null_b
      4: tag_is_null_b
      12: val_is_null_b
      2: box__apply_Zo
      0: val__apply_Zo
      1: ref__apply_Zo
  -1: Pointer_Bool_val, o
    vtable: 0
  -1: Pointer_net_ssl__OpenSslInitSettings_val, o
    vtable: 0
  13: AmbientAuth, o
    vtable: 1
      0: val__create_o
    u2_AmbientAuth_val_None_val
  1: InputStream, o
    vtable: 0
    Stdin
  27: StdStream, o
    vtable: 4
      1: tag_print_oo
      0: tag__err_o
      3: ref__print_oo
      2: tag__out_o
    OutStream
  -1: Pointer_String_val, o
    vtable: 11
      10: ref__alloc_Zo
      0: ref_create_o
      1: ref__update_Zoo
      8: ref__realloc_Zo
  11: Main, o
    vtable: 2
      1: tag_create_oo
      0: runtime_override_defaults_oo
  15: String, o
    vtable: 10
      5: ref_size_Z
      8: val_size_Z
      1: box_size_Z
      9: box_cpointer_Zo
      3: val_cpointer_Zo
      0: ref_cpointer_Zo
      4: ref__set_ZCC
      6: ref_create_Zo
      2: ref_copy_cstring_oo
    u2_String_val_Array_U8_val_val
  6: InputNotify, o
    vtable: 2
      0: ref_apply_oo
      1: ref_dispose_o
  17: Array_String_val, o
    vtable: 8
      0: ref_push_oo
      7: ref_reserve_Zo
      6: ref_create_Zo
  8: Bool, b
    vtable: 24
      2: box_op_not_b
      4: val_op_not_b
      0: val_create_bb
      3: box_op_and_bb
      1: val_op_and_bb
      23: box___digestof_
  3: net_ssl__SSLInit, o
    vtable: 2
      1: val__init_o
      0: box__init_o
  24: F64, d
    vtable: 24
      23: box___digestof_
  25: Stdin, o
    vtable: 5
      1: tag__create_bo
      2: ref__read_b
      4: tag__read_again_o
      3: ref__close_event_o
      0: tag__event_notify_oIIo
    InputStream
  0: I32, i
    vtable: 24
      23: box___digestof_
  -1: Pointer_None_val, o
    vtable: 0
  4: U64, W
    vtable: 24
      0: val_create_WW
      2: box_add_WW
      1: val_add_WW
      23: box___digestof_
  12: USize, Z
    vtable: 27
      25: val_bitwidth_Z
      14: box_bitwidth_Z
      10: box_sub_ZZ
      16: val_sub_ZZ
      20: val_shl_ZZ
      8: box_shl_ZZ
      3: val_max_value_Z
      0: val_add_ZZ
      12: box_add_ZZ
      4: val_next_pow2_Z
      15: box_next_pow2_Z
      23: box___digestof_
      7: box_eq_Zb
      19: val_eq_Zb
      11: box_clz_Z
      24: val_clz_Z
      18: val_max_ZZ
      17: box_max_ZZ
      5: val_neg_Z
      2: box_neg_Z
      13: val_min_ZZ
      6: box_min_ZZ
      1: val_create_ZZ
      22: val_lt_Zb
      21: box_lt_Zb
      9: val_gt_Zb
      26: box_gt_Zb
  -1: RuntimeOptions, o
    vtable: 0
  21: Array_U8_val, o
    vtable: 10
      5: ref_size_Z
      8: val_size_Z
      1: box_size_Z
      7: ref_reserve_Zo
      9: box_cpointer_Zo
      3: val_cpointer_Zo
      0: ref_cpointer_Zo
      4: ref_undefined_U8_val_Zo
      6: ref_create_Zo
      2: ref_truncate_Zo
    u2_StrinLINK : fatal error LNK1104: cannot open file 'ssl.lib'
g_val_Array_U8_val_val
  19: Env, o
    vtable: 9
      3: ref__create_Iooo
      6: ref__count_strings_oZ
      1: tag__count_strings_oZ
      5: val__count_strings_oZ
      2: box__count_strings_oZ
      4: val__strings_from_pointers_oZo
      8: box__strings_from_pointers_oZo
      0: ref__strings_from_pointers_oZo
      7: tag__strings_from_pointers_oZo
  1: None, o
    vtable: 7
      6: val_create_o
    u2_AmbientAuth_val_None_val
    u2_InputNotify_ref_None_val
  23: AsioEvent, o
    vtable: 7
      2: box_none_o
      1: val_none_o
      6: val_create_o
      5: val_readable_Ib
      4: box_readable_Ib
      3: box_disposable_Ib
      0: val_disposable_Ib
  29: $0$15, o
    vtable: 7
      6: val_create_o
    $0$6
  0: u2_AmbientAuth_val_None_val, o
    vtable: 0
    None
    AmbientAuth
  7: net_ssl__OpenSslInitLoadSslStrings, o
    vtable: 7
      0: val_apply_W
      6: val_create_o
  5: net_ssl__OpenSslInitSettings, o
    vtable: 0
  2: OutStream, o
    vtable: 2
      1: tag_print_oo
    StdStream
  5: u2_InputNotify_ref_None_val, o
    vtable: 0
    None
  16: U8, C
    vtable: 24
      1: val_create_CC
      2: val_ne_Cb
      0: box_ne_Cb
      23: box___digestof_
  -1: Pointer_U8_val, o
    vtable: 17
      10: ref__alloc_Zo
      8: ref__realloc_Zo
      13: ref__update_ZCC
      11: val__apply_ZC
      3: ref__apply_ZC
      1: box__apply_ZC
      7: ref_is_null_b
      6: box_is_null_b
      4: tag_is_null_b
      12: val_is_null_b
      14: val__offset_Zo
      5: box__offset_Zo
      15: ref__offset_Zo
      0: ref_create_o
      9: ref__copy_to_oZo
      16: val__copy_to_oZo
      2: box__copy_to_oZo

  err:
Building builtin -> D:\Coding\github\ponyc\packages\builtin
Building . -> D:\Coding\Pony\pony-ssl-issue
Building http_server -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_http_server\http_server
Building valbytes -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_valbytes\valbytes
Building collections -> D:\Coding\github\ponyc\packages\collections
Building ponytest -> D:\Coding\github\ponyc\packages\ponytest
Building time -> D:\Coding\github\ponyc\packages\time
Building random -> D:\Coding\github\ponyc\packages\random
Building collections/persistent -> D:\Coding\github\ponyc\packages\collections\persistent
Building debug -> D:\Coding\github\ponyc\packages\debug
Building ponycheck -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck\ponycheck
Building assert -> D:\Coding\github\ponyc\packages\assert
Building itertools -> D:\Coding\github\ponyc\packages\itertools
Building json -> D:\Coding\github\ponyc\packages\json
Building format -> D:\Coding\github\ponyc\packages\format
Building net -> D:\Coding\github\ponyc\packages\net
Building files -> D:\Coding\github\ponyc\packages\files
Building buffered -> D:\Coding\github\ponyc\packages\buffered
Building term -> D:\Coding\github\ponyc\packages\term
Building promises -> D:\Coding\github\ponyc\packages\promises
Building strings -> D:\Coding\github\ponyc\packages\strings
Building signals -> D:\Coding\github\ponyc\packages\signals
Building capsicum -> D:\Coding\github\ponyc\packages\capsicum
Building net_ssl -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_net_ssl\net_ssl
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing .\pony-ssl-issue.obj
detecting Visual Studio via ""%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -prerelease -latest -products *"
searching for D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\ .. \bin\HostX64\x64\link.exe and \bin\HostX64\x64\lib.exe
linker:  D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\link.exe
libtool: D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\lib.exe
libdir:  D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\lib\x64
Linking .\pony-ssl-issue.exe
cmd /C ""D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\link.exe" /DEBUG /NOLOGO /MACHINE:X64 /ignore:4099 /OUT:.\pony-ssl-issue.exe .\pony-ssl-issue.obj /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\lib\x64" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_valbytes" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_http_server" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_net_ssl" /LIBPATH:"D:\Coding\github\ponyc\build\release" /LIBPATH:"D:\Coding\github\ponyc\build\release\..\..\packages" "ssl".lib "crypto".lib  kernel32.lib msvcrt.lib Ws2_32.lib advapi32.lib vcruntime.lib legacy_stdio_definitions.lib dbghelp.lib ucrt.lib libponyrt.lib "
Error:
unable to link: cmd /C ""D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\bin\HostX64\x64\link.exe" /DEBUG /NOLOGO /MACHINE:X64 /ignore:4099 /OUT:.\pony-ssl-issue.exe .\pony-ssl-issue.obj /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\lib\x64" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_valbytes" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_http_server" /LIBPATH:"D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_net_ssl" /LIBPATH:"D:\Coding\github\ponyc\build\release" /LIBPATH:"D:\Coding\github\ponyc\build\release\..\..\packages" "ssl".lib "crypto".lib  kernel32.lib msvcrt.lib Ws2_32.lib advapi32.lib vcruntime.lib legacy_stdio_definitions.lib db

@chalcolith
Copy link
Member

I'm not sure if OpenSSL will work on Windows; when we packaged ssl with the standard library we used LibreSSL on Windows. I'll try to take a look at this in the next couple of days.

This is why I'd like to get Corral to do this for us.

@SeanTAllen
Copy link
Member

@adeel41 can you try using the libressl that is linked to from the README?

@adeel41
Copy link
Author

adeel41 commented Jul 23, 2020

@SeanTAllen I was able to build LibreSSL 3.2.0 on my windows machine using cmake and then msbuild. Then copied the generated file which are crypto-46.lib and ssl-48.lib into my pony project. Then ran the following command corral run -- ponyc -D openssl_0.9.0 but again only an obj is generated and linker returned an error.

I realized that the net_ssl package I am using is looking for ssl and crypto files, so I renamed the ssl-48.lib to ssl.lib and crypto-46.lib to crypto.lib. Ran the same command again and this time an executable is generated. But the same issue, running that executable does not output "Hello World".

What I've learned so far is that you can use both OpenSSL and LibreSSL with Pony but the generated lib files should be renamed to "ssl.lib" and "crypto.lib".

So in a nutshell
OpenSSL generated lib files names are libssl.lib and libcrypto.lib
LibreSSL generated lib file names are ssl-48 and crypto-46.lib

OpenSSL 1.1.1h works with Pony given that files are renamed to ssl.lib and crypto.lib and use corral run -- ponyc -D openssl_1.1.x

LibreSSL 3.2.0 works with Pony given that files are renamed to ssl.lib and crypto.lib and use corral run -- ponyc -D openssl_0.9.0

So either I use OpenSSL or LibreSSL, my trivial pony code doesn't work. here is the link to the source code

To be honest I think it must be something silly from my end 😄. The code prints "Hello World" if I don't use "http_server" statement

@SeanTAllen
Copy link
Member

@adeel41 the README has a link to prebuilt openssl windows libressl. Did the prebuilt one not work?

@adeel41
Copy link
Author

adeel41 commented Jul 23, 2020

@SeanTAllen The last prebuilt windows libressl package is 2.5.5 (9-July-2017) which is a bit older than current one 3.2.0 (31 May 2020). Which is why I tried the latest one.

I've just tried it now. The x64 folder contains libcrypto-41.lib and libssl-43.lib files. I've then renamed them to crypto.lib and ssl.lib. I was able to compile and an executeable is generated but again same thing, "Hello World" wasn't printed on the screen.

@SeanTAllen
Copy link
Member

@adeel41 when you run the program, is there any output? does it hang? what is happening beyond "Hello World" not being printed?

@adeel41
Copy link
Author

adeel41 commented Jul 28, 2020

@SeanTAllen there is no output. The program doesn't hang. It just exits without any error message. Just like the attached screenshot
image

@SeanTAllen
Copy link
Member

@adeel41 Thanks.

Can you print out a listing of the files in the directory and include on this issue?

@adeel41
Copy link
Author

adeel41 commented Jul 28, 2020

sure @SeanTAllen

ssl.lib and crypto.lib1 in the root are copied from libressl_prebuilt folder (contains version 2.5.5)

image

@SeanTAllen
Copy link
Member

can you remove all the pony-ssl-issue files (exe, exp, etc) and try rebuilding and let me know if anything changes?

also can you include the source from main.pony here?

@adeel41
Copy link
Author

adeel41 commented Jul 29, 2020

@SeanTAllen

Removed all pony-ssl-issue related files but same behaviour as previously. Here is the main.pony source code

use "http_server"

actor Main
    new create(env: Env) =>
        env.out.print("Hello World")

Please have a look at the following repo which I created for this issue. https://github.com/adeel41/pony-ssl-issue
It contains all lib files for latest libressl, 2.5.5 and openssl 1.1.1h

@SeanTAllen
Copy link
Member

I don't have a windows setup to verify this with. One Linux the example program works fine for me.

@adeel41 does:

actor Main
    new create(env: Env) =>
        env.out.print("Hello World")

compile and run properly for you?

@adeel41
Copy link
Author

adeel41 commented Jul 30, 2020

@SeanTAllen Yes it does.

The problem starts only when adding a use "http_server" statement.

@adeel41
Copy link
Author

adeel41 commented Jul 30, 2020

@SeanTAllen I've just created a Windows 10 VM on Azure and was able to replicate. I can share the VM's credentials with you if you want?

Output from console

PS C:\Users\Pony\Downloads\pony-ssl-issue> corral run -- ponyc -D openssl_0.9.0
  exit: Exited(0)
  out:
   Creating library .\pony-ssl-issue.lib and object .\pony-ssl-issue.exp

  err:
Building builtin -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\builtin
Building . -> C:\Users\Pony\Downloads\pony-ssl-issue
Building http_server -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_http_server\http_server
Building valbytes -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_valbytes\valbytes
Building collections -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\collections
Building ponytest -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\ponytest
Building time -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\time
Building random -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\random
Building collections/persistent -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\collections\persistent
Building debug -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\debug
Building ponycheck -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck\ponycheck
Building assert -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\assert
Building itertools -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\itertools
Building json -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\json
Building format -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\format
Building net -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\net
Building files -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\files
Building buffered -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\buffered
Building term -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\term
Building promises -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\promises
Building strings -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\strings
Building signals -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\signals
Building capsicum -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\capsicum
Building net_ssl -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_net_ssl\net_ssl
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing .\pony-ssl-issue.obj
Linking .\pony-ssl-issue.exe

PS C:\Users\Pony\Downloads\pony-ssl-issue> .\pony-ssl-issue.exe
PS C:\Users\Pony\Downloads\pony-ssl-issue>

@EpicEric
Copy link
Contributor

Could you try compiling passing the --debug flag to ponyc and see what is outputted?

@adeel41
Copy link
Author

adeel41 commented Jul 30, 2020

@EpicEric Same result as previous try.

PS C:\Users\Pony\Downloads\pony-ssl-issue> corral run -- ponyc --debug -D openssl_0.9.0
  exit: Exited(0)
  out:
   Creating library .\pony-ssl-issue.lib and object .\pony-ssl-issue.exp

  err:
Building builtin -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\builtin
Building . -> C:\Users\Pony\Downloads\pony-ssl-issue
Building http_server -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_http_server\http_server
Building valbytes -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_valbytes\valbytes
Building collections -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\collections
Building ponytest -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\ponytest
Building time -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\time
Building random -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\random
Building collections/persistent -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\collections\persistent
Building debug -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\debug
Building ponycheck -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck\ponycheck
Building assert -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\assert
Building itertools -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\itertools
Building json -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\json
Building format -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\format
Building net -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\net
Building files -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\files
Building buffered -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\buffered
Building term -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\term
Building promises -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\promises
Building strings -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\strings
Building signals -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\signals
Building capsicum -> C:\Users\Pony\Downloads\ponyc-x86-64-pc-windows-msvc\packages\capsicum
Building net_ssl -> C:\Users\Pony\Downloads\pony-ssl-issue\_corral\github_com_ponylang_net_ssl\net_ssl
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing .\pony-ssl-issue.obj
Linking .\pony-ssl-issue.exe

PS C:\Users\Pony\Downloads\pony-ssl-issue> .\pony-ssl-issue.exe
PS C:\Users\Pony\Downloads\pony-ssl-issue>

@chalcolith
Copy link
Member

OK, I've finally had a bit of time to look at this. I've made a PR for net_ssl that adds a utility to download and build LibreSSL (.\make.ps1 libs; you need 7z.exe in your PATH and Visual Studio to run it). This will build and run the tests on Windows successfully.

@chalcolith
Copy link
Member

You'll need to --define=openssl_0.9.0 to use LibreSSL on Windows.

@chalcolith
Copy link
Member

chalcolith commented Jul 30, 2020

With your example @adeel41, if I copy the LibreSSL libs from doing .\make.ps1 libs in my net_ssl branch into _corral\github_com_ponylang_net_ssl, and run corral run -- ponyc --debug --define=openssl_0.9.0 --output .\build\debug .\ssl_test, then the resulting ssl_test.exe program runs and prints "Hello world".

@adeel41
Copy link
Author

adeel41 commented Jul 31, 2020

@kulibali that worked. I Thanks for making it easier by scripting those manual steps. Not everyone on windows machine build their own cake and eat it 😄

FYI the console output

D:\Coding\Pony\pony-ssl-issue [master ≡ +0 ~0 -2 !]> corral run -- ponyc --debug --define=openssl_0.9.0 --output build\debug\ssl_test
run: ponyc --debug --define=openssl_0.9.0 --output build\debug\ssl_test
  exit: Exited(0)
  out:
   Creating library build\debug\ssl_test\pony-ssl-issue.lib and object build\debug\ssl_test\pony-ssl-issue.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

  err:
Building builtin -> D:\Coding\github\ponyc\packages\builtin
Building . -> D:\Coding\Pony\pony-ssl-issue
Building http_server -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_http_server\http_server
Building valbytes -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_valbytes\valbytes
Building collections -> D:\Coding\github\ponyc\packages\collections
Building ponytest -> D:\Coding\github\ponyc\packages\ponytest
Building collections/persistent -> D:\Coding\github\ponyc\packages\collections\persistent
Building debug -> D:\Coding\github\ponyc\packages\debug
Building ponycheck -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_mfelsche_ponycheck\ponycheck
Building assert -> D:\Coding\github\ponyc\packages\assert
Building itertools -> D:\Coding\github\ponyc\packages\itertools
Building json -> D:\Coding\github\ponyc\packages\json
Building format -> D:\Coding\github\ponyc\packages\format
Building net -> D:\Coding\github\ponyc\packages\net
Building files -> D:\Coding\github\ponyc\packages\files
Building buffered -> D:\Coding\github\ponyc\packages\buffered
Building term -> D:\Coding\github\ponyc\packages\term
Building promises -> D:\Coding\github\ponyc\packages\promises
Building strings -> D:\Coding\github\ponyc\packages\strings
Building signals -> D:\Coding\github\ponyc\packages\signals
Building capsicum -> D:\Coding\github\ponyc\packages\capsicum
Building net_ssl -> D:\Coding\Pony\pony-ssl-issue\_corral\github_com_ponylang_net_ssl\net_ssl
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing build\debug\ssl_test\pony-ssl-issue.obj
Linking build\debug\ssl_test\pony-ssl-issue.exe

D:\Coding\Pony\pony-ssl-issue [master ≡ +0 ~0 -2 !]> cd .\build\debug\ssl_test\
D:\Coding\Pony\pony-ssl-issue\build\debug\ssl_test [master ≡ +0 ~0 -2 !]> .\pony-ssl-issue.exe
Hello World
D:\Coding\Pony\pony-ssl-issue\build\debug\ssl_test [master ≡ +0 ~0 -2 !]>

@chalcolith
Copy link
Member

Cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants