- 1 year ago
How to add directories to the PKG_CONFIG_PATH environment variable
To add directories to the PKG_CONFIG_PATH
environment variable, you can follow these steps:
Determine the Directories: Identify the directories that you want to add to the
PKG_CONFIG_PATH
variable. These directories should contain the.pc
files used by thepkg-config
utility.Check the Current Value: Before modifying the
PKG_CONFIG_PATH
variable, it's a good practice to check its current value. Open a terminal or command prompt and execute the following command:bashecho $PKG_CONFIG_PATH # On Linux or macOS
powershellecho %PKG_CONFIG_PATH% # On Windows
This will display the current value of the
PKG_CONFIG_PATH
variable, if it is already set.Set the Environment Variable: To add directories to the
PKG_CONFIG_PATH
variable, you can use the following commands:Linux and macOS (Bash shell):
bashexport PKG_CONFIG_PATH=/path/to/dir1:/path/to/dir2:$PKG_CONFIG_PATH
Windows (Command Prompt):
powershellset PKG_CONFIG_PATH=C:\path\to\dir1;C:\path\to\dir2;%PKG_CONFIG_PATH%
Make sure to replace
/path/to/dir1
and/path/to/dir2
with the actual directory paths you want to add. If you have multiple directories, separate them with:
on Linux and macOS or;
on Windows. The$PKG_CONFIG_PATH
or%PKG_CONFIG_PATH%
at the end of the command ensures that the existing value ofPKG_CONFIG_PATH
is preserved.Verify the Changes: To confirm that the directories are added to the
PKG_CONFIG_PATH
variable, execute the same command as in step 2 to display the updated value.bashecho $PKG_CONFIG_PATH # On Linux or macOS
powershellecho %PKG_CONFIG_PATH% # On Windows
The output should include the directories you added, along with any previous values.
By following these steps, you can add directories to the PKG_CONFIG_PATH
environment variable, allowing the pkg-config
utility to locate the necessary .pc
files when searching for dependencies.