Reputation: 752
I'm having trouble getting my setup.py script to work properly when linking to FORTRAN libraries.
I have almost no experience with libraries, so I may use the incorrect terminology. I have a fortran module which uses the FMLIB fortran package. The FMLIB package contains three f95 files which I have compiled to .o files. This module is in turn used by a python module. In the setup.py file, I use Extension:
shapelets = Extension('PyCosmology.shapelets.fort.shapelets',
['PyCosmology/shapelets/fort/find_coeffs.f90'],
libraries = [<DIRECTORY>./FM.o'
'<DIRECTORY>/FMSAVE.f95',
'<DIRECTORY>/FMZM90.f95'],
extra_f90_compile_args=['-Wtabs'],
f2py_options=['--quiet'])
However, when I try installing it says that it can't use FMZM because no .mod file can be found. Am I supposed to use a different keyword in Extension to link to the libraries, or link to the mod files instead? Or is there something else I should be doing? The documentation for distutils is relatively sparse.
Upvotes: 1
Views: 781
Reputation: 752
Figured it out.
Just need to add include_dirs = ['<DIRECTORY WITH .MOD FILES>']
and library_dirs = [<DIRECTORY>]
and then change the libraries keyword to contain only filenames with no path.
Seems to work.
Upvotes: 2