Clang++ cannot working

Question:
When I try to compile my cpp file as:
clang++ test_llvm.cpp -o test_llvm
it does not work. Rather gives an error as:

"/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: /tmp/test_llvm-532f9d.o:(.data+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)"

code snippet
image

Please share the repl link. So far, my first guess is that the Makefile or CMakeLists you have are missing a linking rule or command for the target test_llvm from test_llvm.cpp. I think you may not be linking the LLVM IR library properly.

By library, I mean the result of compiling the header and its corresponding definition file.

2 Likes