Sam Estep
Sam Estep

Reputation: 13324

How should I set the Vulkan SDK environment variables?

The Linux Getting Started Guide for the Vulkan SDK gives instructions for setting up the runtime environment to allow applications to see the local Vulkan SDK installation:

Set up these variables in your environment after you have set your VULKAN_SDK variable:

$ export PATH=$PATH:$VULKAN_SDK/bin
$ export LD_LIBRARY_PATH=$VULKAN_SDK/lib
$ export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d

What am I supposed to do with these commands? Currently I just put them at the end of my ~/.bashrc file:

$ tail -4 ~/.bashrc
VULKAN_SDK=~/vulkan/VulkanSDK/1.0.13.0/x86_64
export PATH=$PATH:$VULKAN_SDK/bin
export LD_LIBRARY_PATH=$VULKAN_SDK/lib
export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d

This has seemed to work so far, but doesn't this only set the variables in Bash? What if I'm using a different shell or an IDE?

Is this the way I should set the Vulkan SDK environment variables, or is there a better way?

Upvotes: 2

Views: 14019

Answers (3)

Rene Lindsay
Rene Lindsay

Reputation: 11

The best place to set your environment variables depends greatly on your use case, and what distro you are using. However, if you're running an IDE from an Ubuntu desktop, and you want these variables available globally, I would recommend placing them in your ~/.profile file, rather than ~/.bashrc.

~/.bashrc is sourced whenever you start a bash terminal, so will only work for tools that are run from the terminal, but not for tools that are started from the desktop launcher.

~/.profile, on the other hand, is sourced when you log in, so its variables are available globally, from the terminal AND the desktop. However, for ~/.profile, you must log out and back in, for changes to take effect.

Alternatively, as ratchet freak said, most (but not all) IDE's provide their own facility for setting environment variables. This is true for Code::Blocks and Qt Creator, but NOT Android Studio. So, personally, I still prefer placing them in ~/.profile.

Upvotes: 1

Karl Schultz
Karl Schultz

Reputation: 1566

SDK Versions prior to 1.0.13.0 used to copy the json files that define the layers to /etc/vulkan/explicit_layer.d. This made it less necessary to set VK_LAYER_PATH.

Starting with 1.0.13.0, the SDK no longer puts files into system directories. So instead of pointing to the json files in $VULKAN_SDK/etc/explicit_layer.d with VK_LAYER_PATH you can instead copy the contents of $VULKAN_SDK/etc/explicit_layer.d to ~/.local/share/vulkan/explicit_layer.d.

The Vulkan loader searches for layers in ~/.local/share/vulkan/explicit_layer.d in addition to /etc/vulkan/explicit_layer.d and /usr/share/vulkan/explicit_layer.d

Upvotes: 5

ratchet freak
ratchet freak

Reputation: 48216

In an IDE there will be a way to set environment variables for the running program. Those settings are often found along with the command line arguments setting.

In the program itself you can use setenv(3) in linux or _putenv_s in windows before the vulkan loader gets loaded.

Upvotes: 0

Related Questions