# Shared library option in fpm

**URL:** <https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886>\
**Category:** Help\
**Created:** [December 1, 2023, 12:46am UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886 "2023-12-01T00:46:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwparis](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mwparis/32/3257_2.png) [@mwparis](https://fortran-lang.discourse.group/u/mwparis)\
**Post date:** [December 1, 2023, 12:46am UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/1 "2023-12-01T00:46:17Z")

</div>

Continuing the discussion from [Fortran package manager or python package manager?](https://fortran-lang.discourse.group/t/fortran-package-manager-or-python-package-manager/133/4): I’m also aware of this discussion: [https://github.com/fortran-lang/fpm/discussions/655](https://github.com/fortran-lang/fpm/discussions/655) (and that there’s a command line work-around). Is this the full story to date? Or have I missed the labors of some kind soul who has put this into play? Many thanks.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 2, 2023, 10:58pm UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/2 "2023-12-02T22:58:55Z")

</div>

Is your question how to create a shared library in fpm? I think we need to support it.

(I updated the title of this thread to reflect it. Feel free to change it.)

---

<div class="post-metadata">

**Author:** ![mwparis](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mwparis/32/3257_2.png) [@mwparis](https://fortran-lang.discourse.group/u/mwparis)\
**Post date:** [December 4, 2023, 10:01pm UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/3 "2023-12-04T22:01:27Z")

</div>

Yes, that’s the question – thanks for your reply and confirmation that it is not yet implemented.

---

<div class="post-metadata">

**Author:** ![mwparis](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mwparis/32/3257_2.png) [@mwparis](https://fortran-lang.discourse.group/u/mwparis)\
**Post date:** [December 5, 2023, 3:36pm UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/4 "2023-12-05T15:36:36Z")

</div>

I think you’re right – it would be great if it were supported. My interest is in using python ctypes for python-fortran interoperability. If I understand correctly (and I may not have this story right), the ctypes.CDLL class is the only way to interact with fortran dynamic (.so file) libraries within the ctypes package. (Please correct me if this is wrong.) Thanks again.

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [December 5, 2023, 4:43pm UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/5 "2023-12-05T16:43:01Z")

</div>

```auto
import numpy as np
mylib = np.ctypeslib.load_library(<shared_lib_name>,<abs_folder_path>)

```

Numpy has a wrapper around ctypes.cdll that is a bit more robust [C-Types foreign function interface (numpy.ctypeslib) — NumPy v1.26 Manual](https://numpy.org/doc/stable/reference/routines.ctypeslib.html).

> But there are cross-platform considerations, such as library file extensions, plus the fact Windows will just load the first library it finds with that name. NumPy supplies the load\_library function as a convenience.

---

<div class="post-metadata">

**Author:** ![mwparis](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mwparis/32/3257_2.png) [@mwparis](https://fortran-lang.discourse.group/u/mwparis)\
**Post date:** [December 5, 2023, 11:36pm UTC](https://fortran-lang.discourse.group/t/shared-library-option-in-fpm/6886/6 "2023-12-05T23:36:26Z")

</div>

I didn’t understand that excerpt you provided until I read the page. Here’s the excerpt in full:

 ![Screen Shot 2023-12-05 at 4.35.17 PM](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/9/9fed8a56f74b69d69ff93c0421fc9c9d74ba20cc.png)
