'lld-link cannot find libcmt.lib when cross-compiling

I use the command

clang -v -fuse-ld=lld-link -target x86_64-pc-win32 out.0.ll -o out.exe

to turn LLVM IR code into an executable file

The command works flawlessly on my windows machine, but when I try running it on linux to cross-compile for windows it gives the following error message:

gbr22@instance-1:~/llvmtest$ clang -v -fuse-ld=lld-link -target x86_64-pc-win32 out.0.ll -o out.exe
clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-7/bin/clang" -cc1 -triple x86_64-pc-windows-msvc19.11.0 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name out.0.ll -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v -resource-dir /usr/lib/llvm-7/lib/clang/7.0.1 -fdebug-compilation-dir /home/gbr22/llvmtest -ferror-limit 19 -fmessage-length 120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/out-db8d92.o -x ir out.0.ll
clang -cc1 version 7.0.1 based upon LLVM 7.0.1 default target x86_64-pc-linux-gnu
warning: overriding the module target triple with x86_64-pc-windows-msvc19.11.0 [-Woverride-module]
1 warning generated.
 "/usr/lib/llvm-7/bin/lld-link" -out:out.exe -defaultlib:libcmt -libpath:lib/amd64 -nologo /tmp/out-db8d92.o
lld-link: error: could not open libcmt.lib: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How could I resolve this issue?

Here is a link to the file if that helps.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source