# How to indicate a specific path to julia libdl find\_library()?

**URL:** <https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794>\
**Category:** General Usage\
**Tags:** c\
**Created:** [September 7, 2021, 9:12am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794 "2021-09-07T09:12:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julie96](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Julie96](https://discourse.julialang.org/u/Julie96)\
**Post date:** [September 7, 2021, 9:12am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/1 "2021-09-07T09:12:58Z")

</div>

copy paste of this [thread](https://stackoverflow.com/questions/68941243/how-to-indicate-a-specific-path-to-julia-libdl-find-library) :

I’m trying to indicate a specific path to `find_library()`. Based on the [doc](https://docs.julialang.org/en/v1/stdlib/Libdl/), `find_library()`

> Searches for the first library in names in the paths in the locations list, DL\_LOAD\_PATH, or system library paths (in that order) which can successfully be dlopen’d`

My library `foo.dll` is located at `\library\` unfortunately, I don’t know how to specify it !

### 1st try : Set the `location` inside find\_library()

```julia-auto
const _LIB = find_library("foo.dll", raw"\library")` gave me the following error : 
MethodError: no method matching joinpath(::Char, ::String) Closest candidates are: joinpath(::AbstractString, ::AbstractString...) 

```

### 2nd Try : Set `DL_LOAD_PATH`

```
DL_LOAD_PATH = raw"../library" (or `DL_LOAD_PATH = raw"/library`) but then : `_LIB==""`

```

NB : The dll is readable : actually, my code can find it if i place it in my windows path, but i would like to make something more portable)

**EDIT** :

**my path :**

```julia-auto
.
├── library
│ └── foo.dll
└── src
    ├── MyPackage.jl
    └── types.jl

```

Thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 7, 2021, 9:59am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/2 "2021-09-07T09:59:28Z")

</div>

On Windows, you should use `PATH`(edit the system environment variable) instead of `DL_LOAD_PATH`. 🙂

---

<div class="post-metadata">

**Author:** ![Julie96](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Julie96](https://discourse.julialang.org/u/Julie96)\
**Post date:** [September 7, 2021, 11:45am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/3 "2021-09-07T11:45:05Z")

</div>

Hi, thanks for your answers. Is there a way to specify the path inside my julia script (with find\_library for instance) ?

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 7, 2021, 3:59pm UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/4 "2021-09-07T15:59:12Z")

</div>

you could use an absolute path(don’t forget to norm it with `normpath`).

---

<div class="post-metadata">

**Author:** ![Julie96](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Julie96](https://discourse.julialang.org/u/Julie96)\
**Post date:** [September 8, 2021, 8:47am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/5 "2021-09-08T08:47:51Z")

</div>

Unfortunately, I’m still not able to use find\_library with my path

```julia-auto
 LoadError: MethodError: no method matching joinpath(::Char, ::String)
Closest candidates are:
  joinpath(::AbstractString, ::AbstractString...) at path.jl:255

```

??

### what I tried :

```julia-auto
CURRENT_PATH = @ __DIR__ # "C:\\Users\\julie\\mypackage\\src"
DL_LOAD_PATH = joinpath(@ __DIR__ , "..", "library") #"C:\\Users\\julie\\mypackage\\src\\..\\library"
const _LIB = find_library("Bid.dll", DL_LOAD_PATH) #ERROR ? 

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [September 8, 2021, 9:08am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/6 "2021-09-08T09:08:19Z")

</div>

Could you try `find_library(joinpath(DL_LOAD_PATH, "Bid.dll"))`? IIRC, the second argument of `find_library` should be a `Vector`, so this might also work: `find_library("Bid.dll", [DL_LOAD_PATH])`

---

<div class="post-metadata">

**Author:** ![Julie96](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Julie96](https://discourse.julialang.org/u/Julie96)\
**Post date:** [September 8, 2021, 9:20am UTC](https://discourse.julialang.org/t/how-to-indicate-a-specific-path-to-julia-libdl-find-library/67794/7 "2021-09-08T09:20:24Z")

</div>

`const _LIB = find_library("Bid.dll", [DL_LOAD_PATH])` worked like a charm, thanks a lot !
