Replies: 5 comments
-
I don't think it's possible yet (@awvwgk or @LKedward can confirm), but for now you can do this step by hand. For example with GFortran:
|
Beta Was this translation helpful? Give feedback.
-
We currently mainly target the creation of executables with fpm. Libraries both static and dynamic are currently not really well supported, but on our roadmap, especially for compatibility with other non-Fortran languages. When using fpm only for Fortran projects, which are fpm compatible building (shared) libraries seldom comes up, however for projects which interface via C this is highly relevant. There are a couple of things to consider when building shared libraries, especially when considering the particularities of different platforms (rpath linking on Unix, dlls/importlibs on Windows, ...), which we haven't designed yet. |
Beta Was this translation helpful? Give feedback.
-
Agree that this is a very important use case that we should eventually support (e.g., for building shared libs for use by Python). FoBiS has this feature, and it's the last remaining thing I use FoBiS for since I do need to build shared libs and it makes that very easy. |
Beta Was this translation helpful? Give feedback.
-
Hi, I wanted to continue the discussion around this topic. Since I'm trying to use more and more fpm, creation of shared libraries is a key step since I use them for (a) calling within an exe and (b) for Python APIs development. I thought about some ideas for how to manage this from the fpm-user perspective, and then see if from there something can be implemented:
[install]
shared=true
For instance: with gfortran on windows, doing With something like this, one could then invoke What are your thoughts ? P.S.: For a single file I have compiled the following compile patterns : gfortran + linux >gfortran -cpp -O3 -fpic -c <name>.f90
>gfortran -shared -o lib<name>.so <name>.o gfortran + windows >gfortran -cpp -O3 -fpic -c <name>.f90
>gfortran -shared -static -o lib<name>.so <name>.o ifort + linux >ifort -fpp -O3 -fpic -c <name>.f90
>ifort -shared -o lib<name>.so <name>.o ifort + windows >ifort -cpp -O3 -fpic -c <name>.f90
>ifort -dll -exe:<name>.dll <name>.obj Here some findings that you might be aware of but just in case they can be useful:
subroutine myfun(args) bind(c)
#if _WIN32 & __INTEL_COMPILER
!DEC$ ATTRIBUTES DLLEXPORT :: myfun
#endif
...
end subroutine That will be portable with any permutation of (gfortran,ifort)+(windows,linux)
|
Beta Was this translation helpful? Give feedback.
-
The implementation of this feature doesn't seem too difficult (when creating static library, also create a shared library if it was asked for). I think the interesting design question is exactly how to expose the options to the user. My inclination is that |
Beta Was this translation helpful? Give feedback.
-
Newbie here
Not sure if I'm just not searching hard enough. Is it possible to build a shared library with fpm, kinda like how cargo can with
cargo new <my_project> --lib
?Beta Was this translation helpful? Give feedback.
All reactions