Fpm with dislin

I wanna use the dislin graphical library in my fpm project for Windows 10. Usually, I compile with the command

gfortran main.f90 -Ic:\dislin\gf\real64  c:\dislin\dismg_d.a -luser32 -lgdi32  -lopengl32

I find some information under Link external libraries

But I still could not figure out how to use it.

Use system-installed modules


fpm cannot automatically locate external module files; it is the responsibility of the user to specify the necessary include directories using compiler flags such that the compiler can locate external module files during compilation.

putting it there gives:

my manifest looks like

Your fpm.toml should probably look a bit closer to this

link = ["user32", "gdi32", "opengl32"]
# If you are USEing and external modules in your code place them below
external-modules = ["netcdf", "h5lt"]


Including the correct paths should probably be done via the --flag option, the fpm environmental variables or a response file.

Relevant Docs sections:

I updated the manifest now:

auto-executables = true
auto-tests = true
auto-examples = true
external-modules = ["dislin"]
link = [ "user32" , "gdi32",  "opengl32" ]

and fpm run is showing pretty much the same output

$ fpm run --Ic:\dislin\gf\real64  c:\dislin\dismg_d.a
UNKNOWN LONG KEYWORD: --Ic:dislingfreal64
version         v  F        [F]
verbose         V  F        [F]
usage           u  F        [F]
target             F        [" "]
runner             F        [" "]
profile            F        [" "]
no-prune           F        [F]
list               F        [F]
link-flag          F        [" "]
help            h  F        [F]
flag               F        [" "]
example            F        [F]
directory       C  F        [" "]
cxx-flag           F        [" "]
cxx-compiler       F        [" "]
compiler           F        ["gfortran"]
c-flag             F        [" "]
c-compiler         F        [" "]
archiver           F        [" "]
all                F        [F]

000001[run                ]

My code is

program main_fpm
  use Dislin ! Dislin module
  implicit none

  integer (4), parameter :: x=4, y=4
  real(8), dimension(x,y) :: r

  call random_number (r)

  call qplclr (r,x,y) ! dislin quickplot routine
end program main_fpm

Try running it like

fpm run --flag "-Ic:\dislin\gf\real64"
fpm run -h

Contains some good info on how to pass these flags to the compiler. Let us know if you think something can be improved.

I still get the error:

$ fpm run --flag "-Ic:\dislin\gf\real64"
first_steps.exe                        failed.
[100%] Compiling...
: build\gfortran_B5883862FD3CD98A\first_steps\app_main.f90.o:main.f90:(.text+0x98): undefined refere
nce to `qplclr_'
collect2.exe: error: ld returned 1 exit status
<ERROR> Compilation failed for object " first_steps.exe "
<ERROR>stopping due to failed compilation

Where to put this


which is used in the cmd.

gfortran main.f90 -Ic:\dislin\gf\real64  c:\dislin\dismg_d.a -luser32 -lgdi32  -lopengl32

The first part seems to be adjusted with the --flag option. The last part was put in the link in .toml file.

As to the command

fpm run -h

it shows a lot of information and i am into it now. Surely will give feedback!