Skip to main content
added 340 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

It's unclear why you set these variables in your shell's startup scripts, or why you need to set them at all as they should be figured out by the configure script, possibly using pkg-config (so PKG_CONFIG_PATH might still be interesting to modify). I'm ignoring that and will instead be concentrating on how to add to these variables.


The LDFLAGS and CPPFLAGS variables contains command line flags that are passed to tools at various stages when compiling software. These should contain space-delimited flags.

export LDFLAGS=-L/some/directory

Later (note, you only have to export a variable once):

LDFLAGS="$LDFLAGS -L/other/directory"

Or,

LDFLAGS+=" -L/other/directory"

The PKG_CONFIG_PATH variable is used by the pkg-config tool. It's manual states (my emphasis):

PKG_CONFIG_PATH
This can be used to specify a colon-separated list of paths to search for package files. If given, this list of paths is prepended to the standard search path.

So,

export PKG_CONFIG_PATH=/some/directory

Later:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/other/directory

Or,

PKG_CONFIG_PATH+=:/other/directory

The LDFLAGS and CPPFLAGS variables contains command line flags that are passed to tools at various stages when compiling software. These should contain space-delimited flags.

export LDFLAGS=-L/some/directory

Later (note, you only have to export a variable once):

LDFLAGS="$LDFLAGS -L/other/directory"

Or,

LDFLAGS+=" -L/other/directory"

The PKG_CONFIG_PATH variable is used by the pkg-config tool. It's manual states (my emphasis):

PKG_CONFIG_PATH
This can be used to specify a colon-separated list of paths to search for package files. If given, this list of paths is prepended to the standard search path.

So,

export PKG_CONFIG_PATH=/some/directory

Later:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/other/directory

Or,

PKG_CONFIG_PATH+=:/other/directory

It's unclear why you set these variables in your shell's startup scripts, or why you need to set them at all as they should be figured out by the configure script, possibly using pkg-config (so PKG_CONFIG_PATH might still be interesting to modify). I'm ignoring that and will instead be concentrating on how to add to these variables.


The LDFLAGS and CPPFLAGS variables contains command line flags that are passed to tools at various stages when compiling software. These should contain space-delimited flags.

export LDFLAGS=-L/some/directory

Later (note, you only have to export a variable once):

LDFLAGS="$LDFLAGS -L/other/directory"

Or,

LDFLAGS+=" -L/other/directory"

The PKG_CONFIG_PATH variable is used by the pkg-config tool. It's manual states (my emphasis):

PKG_CONFIG_PATH
This can be used to specify a colon-separated list of paths to search for package files. If given, this list of paths is prepended to the standard search path.

So,

export PKG_CONFIG_PATH=/some/directory

Later:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/other/directory

Or,

PKG_CONFIG_PATH+=:/other/directory
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

The LDFLAGS and CPPFLAGS variables contains command line flags that are passed to tools at various stages when compiling software. These should contain space-delimited flags.

export LDFLAGS=-L/some/directory

Later (note, you only have to export a variable once):

LDFLAGS="$LDFLAGS -L/other/directory"

Or,

LDFLAGS+=" -L/other/directory"

The PKG_CONFIG_PATH variable is used by the pkg-config tool. It's manual states (my emphasis):

PKG_CONFIG_PATH
This can be used to specify a colon-separated list of paths to search for package files. If given, this list of paths is prepended to the standard search path.

So,

export PKG_CONFIG_PATH=/some/directory

Later:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/other/directory

Or,

PKG_CONFIG_PATH+=:/other/directory