# What is the search paths for shared object when running an execuable?



## jronald (Jun 25, 2016)

I hope the directory containing the executable is in the highest priority.
But I bet it is not searched at all.


----------



## ljboiler (Jun 25, 2016)

By default, it's not (for security reasons); ldconfig() controls a cached list of all the "safe" shared objects that will be searched when looking for one.

One can use the LD_LIBRARY_PATH environment variable as described in ldconfig() to add to the locations searched.


----------



## jronald (Jun 26, 2016)

```
The [B]ldconfig[/B] utility is used to prepare a set of ``hints'' for use by the
  dynamic linker to facilitate quick lookup of shared libraries available
  in multiple directories.  It scans a set of built-in system directories
  and any [I]directories[/I] specified on the command line (in the given order)
  looking for shared libraries and stores the results in a system file to
  forestall the overhead that would otherwise result from the directory
  search operations the dynamic linker would have to perform to load the
  required shared libraries.
```

This is a part of description of ldconfig(8), so the system directory is in higher priority.
Though "-s" option can be used to exclude system directories for searching, it can not be in lower priority.

Just not perfect.

BTW, the description in man is such a long sentence, not UNIX style some way.
BTW, why there is an additional "()" when using [MAN][/MAN] in the post?


----------



## ShelLuser (Jun 26, 2016)

jronald said:


> BTW, the description in man is such a long sentence, not UNIX style some way.


Not sure I agree, there are other manualpages which contain long sentences. The primary objective should be to relay the required information, which I think is happening here 



jronald said:


> BTW, why there is an additional "()" when using [MAN][/MAN] in the post?


Because a manualpage normally also has a section, which you forgot to mention. So when talking about ldconfig I'd use: ldconfig(8). Or to show the source: [man=8]ldconfig[/man]. Hope this helps.


----------



## SirDice (Jun 27, 2016)

jronald said:


> BTW, why there is an additional "()" when using [MAN][/MAN] in the post?


Because you're using it wrong.
https://forums.freebsd.org/threads/49535/


----------

