# Fpm with dislin

**URL:** https://fortran-lang.discourse.group/t/fpm-with-dislin/6700
**Category:** fpm
**Created:** [October 27, 2023, 4:38pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700 "2023-10-27T16:38:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)
#### Post date: [October 27, 2023, 4:38pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700/1 "2023-10-27T16:38:33Z")

</div>

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

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

```

I find some information under **Link external libraries**

> **[Manifest reference — Fortran Package Manager](https://fpm.fortran-lang.org/spec/manifest.html#include-directory)**

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

## Use system-installed modules

says

_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:

 ![Capture](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/1/143124ef54dc29648f3315ea94bd48d334a8aca5.png)

my manifest looks like

 ![fpm](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/1/1194f3e3eeb9940fbaa1af7d2013f4029b862d4f.png)

---

<div class="post-metadata">

### Author: ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)
#### Post date: [October 27, 2023, 5:30pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700/2 "2023-10-27T17:30:10Z")

</div>

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

```toml
[build]
...
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:

- [external lib linking](https://fpm.fortran-lang.org/spec/manifest.html#link-external-libraries)
- [external modules](https://fpm.fortran-lang.org/spec/manifest.html#use-system-installed-modules)

---

<div class="post-metadata">

### Author: ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)
#### Post date: [October 27, 2023, 5:56pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700/3 "2023-10-27T17:56:47Z")

</div>

I updated the manifest now:

```auto
[build]
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

```auto
$ fpm run --Ic:\dislin\gf\real64 c:\dislin\dismg_d.a
UNKNOWN LONG KEYWORD: --Ic:dislingfreal64
KEYWORD SHORT PRESENT VALUE
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]

UNNAMED
000001[run]

```

My code is

```auto
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

```

---

<div class="post-metadata">

### Author: ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)
#### Post date: [October 27, 2023, 6:21pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700/4 "2023-10-27T18:21:23Z")

</div>

Try running it like

```sh
fpm run --flag "-Ic:\dislin\gf\real64"

```

```auto
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.

---

<div class="post-metadata">

### Author: ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)
#### Post date: [October 27, 2023, 6:45pm UTC](https://fortran-lang.discourse.group/t/fpm-with-dislin/6700/5 "2023-10-27T18:45:33Z")

</div>

I still get the error:

```auto
$ fpm run --flag "-Ic:\dislin\gf\real64"
first_steps.exe failed.
[100%] Compiling...
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe
: 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
STOP 1

```

Where to put this

```auto
c:\dislin\dismg_d.a

```

which is used in the cmd.

```auto
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!
