how to configure linker on Windows

currently I get this message:

> crystal
Error: Cannot locate the .lib files for the following libraries: libcmt,
advapi32, libvcruntime, shell32, ole32, WS2_32, kernel32,
legacy_stdio_definitions, DbgHelp, libucrt

here it says Visual Studio is required:

but here is says you can configure the linker:

so is Visual Studio required or not? if not, how do you get it working with something else?

1 Like

No Windows on sight to test, but basically that PR says that you should be able to replace the default cl.exe with whatever linker you have in your machine by setting CC=<path_to_linker> in the environment variables.

d:\>set CC="d:\Ruby30-x64\msys64\mingw64\bin\ld.exe"

d:\>crystal eval "puts 2+2"
Regex match error: UTF-8 error: byte 2 top bits not 0x80 (ArgumentError)
  from a\crystal\crystal\src\regex\ in 'match_data'
  from a\crystal\crystal\src\ in 'match_at_byte_index'
  from a\crystal\crystal\src\ in 'gsub'
  from a\crystal\crystal\src\compiler\crystal\ in 'codegen'
  from a\crystal\crystal\src\compiler\crystal\ in 'compile:combine_rpath'
  from a\crystal\crystal\src\compiler\crystal\codegen\ in 'compile:combine_rpath'
  from a\crystal\crystal\src\compiler\crystal\command\ in 'eval'
  from a\crystal\crystal\src\compiler\ in '__crystal_main'
  from a\crystal\crystal\src\crystal\ in 'main'
  from a\crystal\crystal\src\crystal\system\win32\ in 'wmain'
  from a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in '__scrt_common_main_seh'
  from C:\Windows\System32\KERNEL32.DLL +97236 in 'BaseThreadInitThunk'
  from C:\Windows\SYSTEM32\ntdll.dll +446161 in 'RtlUserThreadStart'
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug:

so linker is configurable, but mingw won’t work out of box