# Dlopen appending file extensions for shared libraries?

**URL:** <https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761>\
**Category:** General Usage\
**Created:** [November 3, 2023, 3:29pm UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761 "2023-11-03T15:29:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gokhan\_Kof](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gokhan_kof/32/43267_2.png) [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Post date:** [November 3, 2023, 3:29pm UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761/1 "2023-11-03T15:29:11Z")

</div>

In the documentation, it says, in the string, you might omit the file extension (.so, .dylib) , dlopen appends it and loads the library but I cannot get it to work.

`lib = Libdl.dlopen(joinpath(@ __DIR__ , "mylib"))`

`mylib` is actually `mylib.so`

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 3, 2023, 5:27pm UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761/2 "2023-11-03T17:27:33Z")

</div>

> [@Gokhan\_Kof](#):
>
> dlopen appends it and loads the library but I cannot get it to work.

What operating system are you on? The suffix that gets automatically appended should be given by `Libdl.dlext`.

---

<div class="post-metadata">

**Author:** ![Gokhan\_Kof](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gokhan_kof/32/43267_2.png) [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Post date:** [November 3, 2023, 9:19pm UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761/3 "2023-11-03T21:19:54Z")

</div>

I was using Linux through WSL on Windows but what I want to do is throw in shared libraries compiled in Mac OS and Linux into a shared folder so people can access it and use it on the platform they are using. I have the `.dylib` and `.so` files already compiled.  
What I expect is when I execute `lib = dlopen(joinpath(@ __DIR__ , "mylib"))` it should append the extension and get `mylib.dylib` if one is on Mac and `mylib.so` if one is on Linux?

---

<div class="post-metadata">

**Author:** ![Gokhan\_Kof](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gokhan_kof/32/43267_2.png) [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Post date:** [November 6, 2023, 8:54am UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761/4 "2023-11-06T08:54:03Z")

</div>

I resolved this issue using `lib = dlopen(joinpath(@ __DIR__ , "mylib.$(Libdl.dlext)"))` although I think it says in the documentation that dlopen should do this automatically.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2023, 1:11pm UTC](https://discourse.julialang.org/t/dlopen-appending-file-extensions-for-shared-libraries/105761/5 "2023-11-06T13:11:09Z")

</div>

Can you [file an issue?](https://github.com/JuliaLang/julia/issues/new/choose) I suspect that this is a problem with julia on WSL.

Internally, the appended extension is [defined in C code](https://github.com/JuliaLang/julia/blob/d834a4473e6dfdcf072f8b4426c00b0d9faa2d60/src/dlload.c#L26-L34) and _should_ be the same as `Libdl.dlext`, but I’m guessing that on WSL it gets confused about what operating system is running and the two get out of sync.
