ERROR: Clang must be installed in order to build this target

I’ve been trying to generate a clang database to use with my editor on linux for what amounts to 3 days now and UBT doesn’t seem to want to do that. I’ve tried tweaking the ClangPath at Engine/Source/Programs/UnrealBuildTool/Platform/Linux/LinuxToolchain.cs, tried setting environment variables, tried tweaking the Engine/Build/BatchFiles/Linux/Build.sh script but it seems UBT don’t want to work on this mode. And yes, I have both the engine clang toolchain and the compiler installed locally

HI! I just have the same problem and it seems that UBT actually checks for clang.exe path to be present. I tried to generalize it in this PR to work for Mac and Linux.
I tested in Linux and it generated the database.

In case anyone stumbles upon this thread, I’ve just fixed this error error on Windows by setting LLVM_PATH environment variable to a directory where LLVM was installed. See FindToolChainInstallations method in UEBuildWindows.cs for details.

4 Likes

If you are trying to run clang in order to create compile_commands.json then my solution for you is one of two.

If you are on a rolling release OS (like arch linux) then you must have a newer unreal engine version that matches compatibility with your rolling release operating system clang. UE5 wont have this issues with compatibility but ue4 will.

Option two: if you are trying to use ue4 and that error still happens then you can generate compile_commands.json by avoiding clang and instead you would use cmake:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON