In this post I just wana talk about how I manage my Unreal Engine C ++ environment using Clangd, VS Codium and Apx, talking about why and how did I choose this setup for an optimal development experience.
Before kicking off, A huge thanks to unreal-clangd by boocs because of which this is possible :)
Why clangd instead of Microsoft’s C++ extension / VS Code ?
Well there are several benefits of using clangd, as it is a great language server for C++, and its license allows it to be used in various code editors including VS Code, Codium, Code OSS, neovim, emacs. However Epic Games does not support clangd and only “officially support” Microsoft’s C/C++ Extension. And the support honestly has not been the best.. with alot of issues since they started supporting it in Unreal 4.18 in 2017. dealing with slow parsing, constant include errors, intellisense / code completion issues.. many of them required the user to manually fix something or using a patch. Also the license of the Microsoft’s extension does not allow it to be used by other code editors, not even Code OSS which is the open source VS Code Repository.
For those who are unaware VS Code is NOT open source, Code OSS is. Many users including fireship.io falsely say VS Code is open source, the VS Code Binary downloaded from the Microsoft Website is not open source. VS Codium basically gives users Code OSS binary without Microsoft branding and Telemetry. However Clangd extension can be used in any of the three. |
---|
My Workflow !
Before I explain “how ?” here is the workflow in a mermaid chart -
Setup and Pre requisites
An apx container (the one I use for my dev stuff is a crystal linux (arch) container)
VS Codium, clang and dotnet runtime 6.0 inside the apx container.
You can use any container however arch container for development makes more sense in my opinion due to availability of packages and latest binaries.
ame ins dotnet-runtime-6.0 vscodium-bin clang
dotnet runtime 6.0 is required for unreal-clangd. You don’t need the SDK except to see UBT logs.
The Unreal Engine itself, I personally use Epic Asset Manager to install the engine as EAM allows me to manage my marketplace assets, my projects just like Epic Games Launcher would. However it is important to note that no matter how you install the linux unreal engine binary, from the Epic’s website, from EAM installed through flatpak or EAM installed through your native package manager.. The engine will always live outside the container and on your host !
Making Unreal Engine happy
- The Unreal Engine looks for a
code
binary in your $PATH when VS Code is selected as the source code editor in the engine settings. However our code editor lives inside the apx container so the engine will complain that it isn’t able to find VS Code while creating a new C++ project or generating a C++ project.
First lets make VS Codium binary accessable outside the container, apx has a handy command for that
apx arch export --bin codium
For a desktop shortcut we can also do -
apx arch export --app-name codium
Here
arch
is the name of my apx container.The binary now lives in
~/.local/bin/codium
which should be in the PATH if you are using Vanilla OS however you can add~/.local/bin
to the PATH otherwise.Now to make the engine happy we can create a symlink to the VS Codium binary we exported.
ln -s ~/.local/bin/codium ~/.local/bin/code
Engine should be happy now as it calls the code executable which calls codium inside our apx container, If you are instead using Code OSS or VS Code directly you simply need to apx export the code binary and engine will be able to find it.
Setting up Clangd
The Engine should now be able to Create projects, open projects on our code editor, compile the projects all all the good stuff ! Now we will setup unreal-clangd for our Unreal Engine projects in VS Codium. This will require 2 extensions ->
unreal-clangd extension at this point is not available on OpenVSX and must be downloaded manually from the github releases.
Make sure you have clang and dot net runtime 6.0 installed as stated above inside the container. Remember everything except the engine is inside the container, which is exactly what we want. On some distros the clangd language server is provided by llvm package and not the clang package so adapt the instructions according to your container distro.
Now you should be able to generate clangd project by simply opening the command pallete inside VS Codium and selecting unreal clangd command. Follow these instructions from the unreal-clangd’s README. I recommend to go through the unreal-clang’s readme for more info ! During the setup it will open a file picker and make you choose the clangd binary. By default it lives inside our container’s
/usr/bin/clangd
to make it easy for us to choose we can also export clangd binary.apx arch export --bin clangd
Now we can choose it in the file picker as it lives in
~/.local/bin/clangd
the apx export binaries when used from inside the container will simply call
/usr/sbin/clangd
. As remember we are calling the apx export binary from inside the container.
Clangd should now work flawlessly with your Unreal Project ! very quick parsing, with auto complete, intellisense and info on hower !.. For debugging and other functionality please check the unreal-clang’s README.