Kaleidoscope Chapter 8 linker command failed with exit code 1143


I am new to LLVM and wanted to experiment with the Kaleidoscope example. My PC is a Windows 64 bit system. I managed to build LLVM from source with CMake. I managed to build the examples of Kaleidoscope with Visual Studio 15 2017 from the .vcxproj file. The built toy.exe from chapter 8 runs well from the command line and I could enter the function definition for average as in the tutorial. toy wrote output.o to D:\llvm.bld\Debug\bin.

However, when I would like to compile and link the main.cpp as given in the tutorial I get:
clang++.exe: error: linker command failed with exit code 1143 (use -v to see invocation).

The full verbose output is copied below. How do you compile and link main.cpp and output.o on a Windows 64 bit PC?


Ad Huikeshoven

D:\llvm.bld\Debug\bin>clang++ main.cpp output.o -o main -v
clang version 7.0.0 (tags/RELEASE_700/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\LLVM\bin
“D:\LLVM\bin\clang++.exe” -cc1 -triple x86_64-pc-windows-msvc19.16.27025 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -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 “D:\LLVM\lib\clang\7.0.0” -internal-isystem “D:\LLVM\lib\clang\7.0.0\include” -internal-isystem “D:\VisualStudio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include” -internal-isystem “D:\Windows Kits\10\Include\10.0.17763.0\ucrt” -internal-isystem “D:\Windows Kits\10\include\10.0.17763.0\shared” -internal-isystem “D:\Windows Kits\10\include\10.0.17763.0\um” -internal-isystem “D:\Windows Kits\10\include\10.0.17763.0\winrt” -fdeprecated-macro -fdebug-compilation-dir “D:\llvm.bld\Debug\bin” -ferror-limit 19 -fmessage-length 120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.16.27025 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o “C:\Users\Ad\AppData\Local\Temp\main-884d07.o” -x c++ main.cpp
clang -cc1 version 7.0.0 based upon LLVM 7.0.0 default target x86_64-pc-win32
#include “…” search starts here:
#include <…> search starts here:
D:\Windows Kits\10\Include\10.0.17763.0\ucrt
D:\Windows Kits\10\include\10.0.17763.0\shared
D:\Windows Kits\10\include\10.0.17763.0\um
D:\Windows Kits\10\include\10.0.17763.0\winrt
End of search list.
“D:\VisualStudio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe” -out:main -defaultlib:libcmt “-libpath:D:\VisualStudio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib\x64” “-libpath:D:\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64” “-libpath:D:\Windows Kits\10\Lib\10.0.17763.0\um\x64” -nologo “C:\Users\Ad\AppData\Local\Temp\main-884d07.o” output.o
clang++.exe: error: linker command failed with exit code 1143 (use -v to see invocation)