4
export LIBRARY_PATH=.
1
  • -1 You mean what does this command do. Not what does this command line do. I almost thought the question was "What does the command line do"!!
    – barlop
    May 29, 2011 at 18:36

5 Answers 5

6

In Bourne-like shells, it sets the variable ${LIBRARY_PATH} to be the current working directory (at the time at which it is referenced) and exports it for other commands to see.

If you wanted the current directory at the time of export, you would use:

export LIBRARY_PATH=$(pwd)

Note that this command disregards any contents which may have already been assigned to ${LIBRARY_PATH}. If you wish to append to ${LIBRARY_PATH} you could use:

export LIBRARY_PATH=${LIBRARY_PATH}:.

GCC's linker is one such command that will consume ${LIBRARY_PATH}:

The value of LIBRARY_PATH is a colon-separated list of directories, much like PATH. When configured as a native compiler, GCC tries the directories thus specified when searching for special linker files, if it can't find them using GCC_EXEC_PREFIX.

See man gcc and man export for more information.

1

This sets an environment variable LIBRARY_PATH to the current directoty in a shell script, and exports it so that other commands can see this value. This environment variable is checked by the linker to find all the libraries that your code references.

1
  • 2
    It sets the environment variable to a full-stop character. In the specific case of the way LIBRARY_PATH is used by compilers, this means the current directory at time of compilation.
    – Steve Jessop
    Sep 6, 2010 at 12:45
1
export LIBRARY_PATH=.

this command tells the linker to search a library from the current directory.

1
  • No linker is mentioned in this command-line or the original question. The question seems far more straightforward than that.
    – johnsyweb
    Sep 6, 2010 at 23:45
1

This sets the environment variable LIBRARY_PATH. The value is the name of the current directrory. The export instructs the bash, that the variable will be not reside in the shell only but passed to commands started from here.

1
  • 1
    No, the value is the string ".". This represents the current directory when used as a filesystem path, but the shell does not substitute the name of the current directory in there.
    – Steve Jessop
    Sep 6, 2010 at 12:43
1

You are setting the env variable LIBRARY_PATH to the current working directory and exporting it so that it is made available to programs outside the shell, compiler in your case.

This directories you specify in LIBRARY_PATH will be searched after any directories specified on the command line with the option -L, and before the standard default directories (such as /usr/local/lib and /usr/lib).

1
  • 1
    As I've said on the other answers - it sets LIBRARY_PATH to a value which means "the current directory" when the compiler uses it. It doesn't set it to the cwd at the time the export command is executed.
    – Steve Jessop
    Sep 6, 2010 at 12:47

You must log in to answer this question.