# ld.so.conf   and   .profile



## raf_BSD (Oct 12, 2016)

Hi

I'm sorry I'm new here forum FreeBSD and if I do something wrong then sorry

I have a similar problem in Ubuntu I use of such entry for files /etc/ld.so.conf

```
/home/user/<my library>/build/out
```
and for files .profile

```
export MY_LIB="$HOME/<my library>"
```
How to do it FreeBSD ?

Please help


----------



## SirDice (Oct 12, 2016)

It depends on the user's shell. For csh(1) use ~/.cshrc:

```
setenv MY_LIB ${HOME}/<my library>
```
For sh(1) and/or bash(1) use ~/.profile.


----------



## raf_BSD (Oct 12, 2016)

Hi SirDice,

sorry
did not help


----------



## SirDice (Oct 12, 2016)

Can you tell us what you're trying to accomplish?


----------



## raf_BSD (Oct 12, 2016)

it is a dynamic library
I wanted to test it in FreeBSD


----------



## kpa (Oct 12, 2016)

As far as I know the  MY_LIB variable is not used by the FreeBSD dynamic linker. The LD_LIBRARY_PATH variable on the other is probably what you want to use. From rtld(1):


```
The
     following search order is used to locate required shared objects:

           1.   DT_RPATH of the referencing object unless that object also
                contains a DT_RUNPATH tag
           2.   DT_RPATH of the program unless the referencing object contains
                a DT_RUNPATH tag
           3.   Path indicated by LD_LIBRARY_PATH environment variable
           4.   DT_RUNPATH of the referencing object
           5.   Hints file produced by the ldconfig(8) utility
           6.   The /lib and /usr/lib directories, unless the referencing
                object was linked using the “-z nodefaultlib” option
```


----------



## tobik@ (Oct 12, 2016)

raf_BSD said:


> export MY_LIB="$HOME/<my library>"


What does that do in Ubuntu? Is MY_LIB a special environment variable?


raf_BSD said:


> for files /etc/ld.so.conf
> /home/user/<my library>/build/out


I'm guessing here, but create a file /usr/local/libdata/ldconfig/mylib and add

```
/home/user/<my library>/build/out
```
 then run `service ldconfig restart`


----------



## SirDice (Oct 13, 2016)

Probably the best way to test it is to launch your application like this:
`env LD_LIBRARY_PATH=${HOME}/mylibs:${LD_LIBRARY_PATH} /path/to/myapp`

This should work regardless of the shell you're using.


----------



## SirDice (Oct 13, 2016)

raf_BSD please don't post the same question multiple times in different threads. Threads merged.

Rule #10: https://forums.freebsd.org/threads/38922/


----------



## raf_BSD (Oct 13, 2016)

Sorry for the double post


----------



## raf_BSD (Oct 19, 2016)

I not solved the problem,

I use the Windows so

set MY_LIB=c:\mylibs

set PATH=C:\mylibs\build\out

how to do it FreeBSD 
can anyone help ?


----------

