1 (edited by JohnWasilewski 2016-07-02 08:13:01)

Topic: Struggling with DISLIN + GFortran under Raspbian

This is an old discussion, from when I was trying to work out
(a) how to install DISLIN on the RPi,
(b) how to make GFortran work how to make DISLIN link DISLIN code,
(c) how to do that also with Simply Fortran.

It was tricky but I got there.

I am therefore starting, today 30-06-2016, a NEW TOPIC with this name:
DISLIN with GFortran on Raspberry Pi with Raspbian
I will explain fully under that new topic how to do it.
Please look there instead of here.
----
John




THE ORIGINAL START OF THIS NOW-SUPERSEDED TOPIC NOW FOLLOWS:
I have posted the  question shown below on the Google Groups forum for DISLIN users, at
https://groups.google.com/forum/#!topic … VeYv9nYvh8 .
If anyone there gives me the solution, I'll post it here.
If anyone here can show me the solution, I'll post it there.

THE QUESTION

From: John Wasilewski <john@wasilewski.co.uk>
To: dislin-users <dislin-users@googlegroups.com>
Subject: DISLIN with GFortran on Raspberry Pi with Raspbian
Date: Sat, 23 Apr 2016 01:27:11 -0700 (PDT)
Reply-To: dislin-users@googlegroups.com
Sender: dislin-users@googlegroups.com

I can't work out how to build GFortran projects under Raspbian, when calling DISLIN routines.
If anyone could help, I'd be very grateful.
I have been trying to discover how to do it by attempting to build an executable from the DISLIN F90 example, exa_f90.f90

I have GFortran successfully installed, and working properly.
I have installed DISLIN using the INSTALL script.
I put it in /usr/local/dislin
I am using Simply Fortran as my IDE.  This works properly.

I have compiled dislin.mod from dislin.f90, to make sure that dislin.mod has been compiled with the same version of GFortran as I am using for my own source files.  I did this in folder /usr/local/dislin  with the command,

sudo gfortran -c dislin.f90


I am using the linker to load dislin.mod together with my object files.
I am expecting to need also to link libdislin.a .

When I try to build an executable using
- my object files
- the version of dislin.mod that I have compiled with the same compiler version
- libdislin.a ,

I get shedloads of undefined references.

I've tried with
- my object files
- the version of dislin.mod as above
- dislin-10.6.a

..and with
- my object files
- the version of dislin.mod as above
- libdislin.so .

None of these works.

I've run the following commands:

sudo apt-get install libmotif4
sudo apt-get install libmotif4* libmotif-dev
sudo apt-get install xfonts-75dpi
sudo apt-get install xfonts-100dpi

..and I then tried again to build an executable by all the same methods as before.

The IDE I am using is Simply Fortran.
When making each build attempt, I have tried in two ways.  One is by adding both DISLIN files directly to the project.  The other is by specifying these Project options :
   Fortran compiler > -I/usr/local/dislin/gf
   Linker                >  /usr/local/dislin/libdislin.a

By all of these attempts, I just can't get my GFortran projects that USE DISLIN, to work.

CAN ANYONE HELP?
---
John

2 (edited by JohnWasilewski 2016-06-27 17:47:34)

Re: Struggling with DISLIN + GFortran under Raspbian

I have received this reply but it has not helped.

From: Rauthe-Schöch, Armin <armin.rauthe-schoech@mpic.de>
To: "dislin-users@googlegroups.com" <dislin-users@googlegroups.com>
Subject: RE: DISLIN with GFortran on Raspberry Pi with Raspbian
Date: Sat, 23 Apr 2016 13:02:25 +0000
Reply-To: dislin-users@googlegroups.com
Sender: dislin-users@googlegroups.com

Dear John,

can you track in your IDE how the GFortran compiler is called, i.e. with which options ? If I want to compile a DISLIN  program with GFortran on OpenSuSE linux, the following two calls do the trick:

# Compiling
gfortran -c test_dislin.f90 -I/usr/local/dislin/gf
# Linking
gfortran -o test_dislin test_dislin.o -L/usr/local/dislin/gf -ldislin

Hope that helps !

Armin
--
Dr. Armin Rauthe-Schöch
Max Planck Institute of Chemistry
Air chemistry department
Hahn-Meitner-Weg 1
D-55128 Mainz
Germany
Tel. +49-(0)6131-305-4123
I TRIED setting SF project options to:
  Fortran :  -I/usr/local/dislin/gf
  Link      :  -L/usr/local/dislin/gf -ldislin
and no luck.

I've also tried compiling and linking like this:
gfortran -c /usr/local/dislin/examples/exa_f90.f90 -I/usr/local/dislin/gf
This worked, and produced a .o object file, called exa_f90.o.

I then tried linking with each of these in turn:
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/dislin
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/dislin.a
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/libdislin.a
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/libdislin
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/libdislin.so
gfortran -o exa_f90 exa_f90.o /usr/local/dislin/lib/dislin_d-10.6.a

Every attempt either failed to find the library file or found and linked it, but produced acres and acres of unresolved references. 

Tearing my hair out!
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

Helmut Michels (DISLIN author) advised:
please try the link command:
   gfortran -o exa_f90 /usr/local/dislin/examples/exa_f90.o -L/usr/local/dislin -ldislin

My reply:
Using the object file exa_f90.o that I had successfully compiled earlier, I tried the command you advised, with the result shown below (output abridged). 
It seems that the link is failing to find essential parts of dislin.

sudo gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ldislin
exa_f90.o: In function `exa_0_':
exa_f90.f90:(.text+0x38): undefined reference to `metafl_'
exa_f90.f90:(.text+0x44): undefined reference to `setpag_'
exa_f90.o: In function `exa_14_':
exa_f90.f90:(.text+0x2d4): undefined reference to `disini_'
exa_f90.f90:(.text+0x2d8): undefined reference to `pagera_'
:
:
:
:
exa_f90.f90:(.text+0x4bb8): undefined reference to `xaxgit_'
exa_f90.f90:(.text+0x4bbc): undefined reference to `disfin_'
collect2: error: ld returned 1 exit status
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

Although this command did not work,
sudo gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ldislin

...this one (thank you, Armin!) seems as if it HAS worked, though:
gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

At least, I think it has, because it has resulted in no error message (in fact, no output at all from gfortran), and I have found a new file in the current directory, exa_f90,  47.2kB (48,320 bytes) with attributes rwx .

When I try to run it, though, by typing ./exa_f90, I receive an error message,
./exa_f90: error while loading shared libraries: libdislin.so.10: cannot open shared object file: No such file or directory.
Does that mean that, under Linux, compiled executables have to have access to library object  files?

I copied libdislin.so.10  into the same directory as my exa_f90 executable and then tried to run it again, but the result was the same.  I am beginning to sense that this must covered in the manual, but I don't remember seeing it there.
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

The error you received when trying to run the executable is because the runtime loader did not find the shared library in your search path. 

Start by verifying that  libdislin.so.10 is on your system (you can use the find command to locate it).  Then check to see if that directory is in your PATH.

I have used dislin with Ubuntu 14 on an ARM machine without any problem, using the standard compile and link command

gf95link -a  exa_f90

Re: Struggling with DISLIN + GFortran under Raspbian

Many thanks "baf1".  Sorry to call you that, but you haven't mentioned your name.
I've also had some very good help from Armin at Max-Planck Institut, from which I've finally made it work.
The main problem was that I had misunderstood part of teh README file, which I thought meant one did not need to set system variables, path etc, if DISLIN was installed in /usr/local/dislin

I'll post, separately, a complete explanation of how to make it work, for the benefit of others.
---
John

7 (edited by JohnWasilewski 2016-04-26 21:09:50)

Re: Struggling with DISLIN + GFortran under Raspbian

HOW TO MAKE DISLIN WORK WITH SF UNDER RASPBIAN ON THE RPi

(1) Download the Rpi distribution from
     www.dislin.de
      → Downloads
      → Distributions
      → Linux
      → ARM
      → dislin-10.6.linux.arm.tar.gz

     OR from:
     http://www.mps.mpg.de/dislin
      → Downloads
      → Distributions
      → Linux
      → ARM
      → dislin-10.6.linux.arm.tar.gz

(2) Unpack.
      Be sure to install into /usr/local/dislin.
      Install from a CLI by the command,
      sudo ./INSTALL

(3) Read the README file.
      Do what the instructions say, especially this part:
      f) To make DISLIN available for general use, write the
          following commands to your .profile or to /etc/profile

             DISLIN=/usr/local/dislin
             export DISLIN
             PATH=${PATH}:${DISLIN}/bin

             LD_LIBRARY_PATH=$DISLIN:$LD_LIBRARY_PATH
             export LD_LIBRARY_PATH

            Do not make the mistake of thinking that this note...
            The environment variable DISLIN is not necessary if DISLIN
            is installed in the default directory '/usr/local/dislin'.

           ...means that f) can be disregarded, as DISLIN installed in /usr/local/dislin. 

(4) Run these commands, to install some libraries and fonts
      which MIGHT be needed :
      (I do not know for sure whether they are or are not):
      sudo apt-get install libmotif4 libmotif4* libmotif-dev
      sudo apt-get install xfonts-75dpi
      sudo apt-get install xfonts-100dpi

(5) Make sure that dislin.mod has been compiled with whatever
      version of Gfortran is currently installed
      sudo gfortran -c dislin.f90

(6) The example file provided with DISLIN can now be successfully
      compiled with this command from the CLI:   
      gfortran -c exa_f90.f90 -I/usr/local/dislin/gf

      and linked with this command
      gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ -I/usr/local/dislin/gf ldislin

8 (edited by JohnWasilewski 2016-04-25 20:13:50)

Re: Struggling with DISLIN + GFortran under Raspbian

Further to my previous post on this subject, although I have now successfully installed DISLIN and made it work with GFortran on the RPi from the CLI, I have not had any similar success in making it work with Simply Fortran.

I just can't seem to find the correct project files list and project options, that are needed to make it work.

Being guided by the way I made it work from the CLI (full details in previous post), I've tried to do all these, with absolutely no success.

Project files list:
   exa_f90
   /usr/local/dislin/gf/dislin.mod

Project options:
   FIle locations -> Search directories
   Modules/include files: 
      /usr/local/dislin/
      /usr/local/dislin/gf/
   Libraries: 
      /usr/local/dislin/
      /usr/local/dislin/gf/

Project options:
   Compiler flags:
       Fortran:
       Linker  :  -ldislin

Project options:
   Compiler flags:
       Fortran:  -I/usr/local/dislin/gf
       Linker  :  -ldislin

Project options:
   Compiler flags:
       Fortran:  -I/usr/local/dislin/gf
       Linker  :  -L/usr/local/dislin/ -ldislin

Project options:
   Compiler flags:
       Fortran:  -I/usr/local/dislin/gf
       Linker  :  -l/usr/local/dislin/dislin

HAIR TEARING OUT BEGINS.
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

Very kindl Helmut Michels, author of DISLIN, has sent me this message:

Dear John,

good to hear that your problem is solved. I just want to summarize how to compile and link a Fortran code with
Dislin and GFortran on Linux systems and give some more explanations. I suppose that the environment variable
DISLIN is defined with the installation directory of Dislin. For example

                                      DISLIN=/usr/local/dislin
                                      export DISLIN

Otherwise, you have to use the installation directory directly in the commands below. The environment variable
DISLIN is only used in programs for detecting font files and map coordinates. If you don't use this Dislin features,
or Dislin is installed in the default directory /usr/local/dislin, the environment variable DISLIN is not required.

a)   Compiling

      the command is:     gfortran -c  -I$DISLIN/gf     xxx.f90

      The directory $DISLIN/gf contains the Fortran 90 module file 'dislin.mod', which is needed if you have the statement
       'use dislin' in your Fortran code. The statement is not necessary, but it allows the compiler to check the number
       and type of parameters passed to Dislin routines. Unfortunately, the format of 'dislin.mod' differs from gfortran version
       to gfortran version. So, you have to recreate it with your gfortran version:

                                    cd   $DISLIN/gf
                                    gfortran -c  dislin.f90

b) Linking

    linking can be done with the command:   gfortran  xxx.o  -L$DISLIN  -ldislin

    The option -ldisdlin tells the linker to link with the library libdislin.so, and the option -L$DISLIN where to search for
    the library. The command above will create the executable a.out. If you don't like the name a.out, you can change
    it with the -o option. The library libdislin.so is just a link to libdislin.so.10, which is again a link to $DISLIN/lib/dislin-10.6.so.

c) Runtime   

    By default, programs are linked shareable with Dislin. This means that the system must load the Dislin library libdislin.so.10
    into memory, when a Dislin program is executed. The environment variable LD_LIBRARY_PATH tells the system where
    to search for shareable libraries. You have to define it with the Dislin directory:

                                 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DISLIN
                                 export LD_LIBRARY_PATH

    There are other methods such as copying libdislin.so.10 to the directory /usr/lib, but this is not done by a tar.gz
    installation of Dislin.

d) Static Linking

    Shareable linking is nice. The created programs are small and if a bug is fixed in a shareable library, it is automatically
    fixed in your program. You don't have to re-link it.A disadvantage is that the shareable libraries must be available on the
    system, where you want to execute your program. The Dislin distributions for Linux contain shareable and static libraries,
    which you can use for linking. The command for linking with the static library of Dislin is normally:

             gfortran  xxx.o  $DISLIN/libdislin.a  -lGL  -lXm  -lXt  -lX11

    -lGL is the linker option for OpenGL, and -lXm for OpenMotif.

Helmut signed off with...
I hope this brings a little bit light into the darkness.

---
John

Re: Struggling with DISLIN + GFortran under Raspbian

John,

Thank you for sharing everything necessary to get DISLIN working!  I'm sure it'll help out others!  I actually didn't know they had a RPi distribution.

Jeff Armstrong
Approximatrix, LLC

11 (edited by JohnWasilewski 2016-06-27 10:08:44)

Re: Struggling with DISLIN + GFortran under Raspbian

I just cannot find the settings neede to make Simply Fortran compile and build a project with calls to Dislin.  I have struggled on and on for many hours with no success, trying to make SF build the Dislin example, exa_f90.
In the process, I've downloaded the following, to see if they help.
   sudo apt-get install freeglut3-dev
   sudo apt-get install xcompmgr libgl1-mesa-dri
   sudo apt-get install mesa-utils

I can confirm that, using DISLIN installed as I have described, the three commands shown below work perfectly, to compile and then build the executable, which then runs, but how do I make SF do the same thing?  Until I can get this small example program to work, I cannot start using SF for my own projects. Dislin and SF simply must work together if I am to use Fortran to create any standalone executable programs with a GUI and with any graphical output.

Command line operations with GFortran and Dislin that definitely work

It ought to be possible, using these examples, to construct SF settings (options and search paths) that achieve the same result, but I am at my wits end, trying to work out what they are.

COMPILE
gfortran -c exa_f90.f90 -I/usr/local/dislin/gf

LINK (needing runtime .so file)
gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin
Produces executable file size 47.2k

This runs, as long as the executable can find the necessary shared library at runtime.
To achieve that, it seems to be necessary to use these commands first.
             DISLIN=/usr/local/dislin
             export DISLIN
             PATH=${PATH}:${DISLIN}/bin
..and either
             LD_LIBRARY_PATH=$DISLIN:$LD_LIBRARY_PATH
             export LD_LIBRARY_PATH
..Or
             ldconfig /usr/local/dislin

LINK (producing standalone executable)
gfortran -o exa_f90 exa_f90.o  $DISLIN/libdislin.a  -lGL  -lXm  -lXt  -lX11
Produces executable file size 833,4k
This runs as a standalone executable, without needing the environment variable LD_LIBRARY_PATH

Re: Struggling with DISLIN + GFortran under Raspbian

John,

To get DISLIN working with Simply Fortran, you'll need to make Simply Fortran aware of all those environment variables as well.  Depending on your configuration, you'll need to add those environment variables premanently to something like ~/.bash_profile or similar.  This page seems to explain it well for Ubuntu:

https://help.ubuntu.com/community/EnvironmentVariables

Compiling with Simply Fortran shouldn't be a problem, though.  You'd need to add all the flags you have above to your Project Options under "Compiler Flags", of course:

Fortran: -I/usr/local/dislin/gf

Linker: -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

The Linker line above assumes you're building a non-static executable, of course.  You'd need the following for a statically linked executable:

Linker: /usr/local/dislin/libdislin.a  -lGL  -lXm  -lXt  -lX11

Note, though, that Simply Fortran defaults to building static executables.  You'd need to change that behavior on the "Linker" tab in Project Options. 

Also, Simply Fortran does not expand environment variables.  You can see in my suggestions that I never use "$DISLIN" anywhere.  You would need to provide the full path.  Our make system, wmake might expand them, but it isn't a configuration we promote.  It would break, for example, syntax checking.

Jeff Armstrong
Approximatrix, LLC

Re: Struggling with DISLIN + GFortran under Raspbian

Thank you Jeff.  I thought I'd tried all those, without success, but I can't check until I get home tonight, which is where I'm off now!
---
J.

14 (edited by JohnWasilewski 2016-04-27 18:52:14)

Re: Struggling with DISLIN + GFortran under Raspbian

Project options
Static linking: unticked
Fortran flags: -I/usr/local/dislin/gf
Linker flags  : -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin
=====
Success.
=====

But:

When I clicked the > icon to try to run it,
(i) SF generated the Makefile again (I can't think why).
(ii) I get an error: error loading shared libraries: libdislin.so.10 can't open shared object file.
Setting environment variables didn't help.


Project options
Static linking: All ticked
Fortran flags: -I/usr/local/dislin/gf
Linker flags  :  /usr/local/dislin/libdislin.a  -lGL  -lXm  -lXt  -lX11
==============================================================================
Generating Makefile... Okay
==============================================================================
Compiling /usr/local/dislin/examples/exa_f90.f90
Generating target
/usr/bin/ld: cannot find -lGL
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libXm.a(Xmos.o): In function `XmeGetHomeDirName':
(.text+0xa60): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libXm.a(Xmos.o): In function `XmeGetHomeDirName':
(.text+0xab0): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libX11.a(xim_trans.o): In function `_XimXTransSocketINETConnect':
(.text+0xcb0): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Error(E42): Last command making (target) returned a bad status
Error(E02): Make execution terminated

* Failed *


Project options
Static linking: All ticked
Fortran flags: -I/usr/local/dislin/gf
Linker flags  : -l/usr/local/dislin/libdislin.a  -lGL  -lXm  -lXt  -lX11
==============================================================================
Generating Makefile... Okay
==============================================================================
Compiling /usr/local/dislin/examples/exa_f90.f90
Generating target
/usr/bin/ld: cannot find -l/usr/local/dislin/libdislin.a
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Error(E42): Last command making (target) returned a bad status
Error(E02): Make execution terminated

* Failed *

I don't understand why it can't find libdislin.a and ther other things.
Also, I don't understand why, if it can't find libdislin.a, it gives the message.
"cannot find -l/usr/local/dislin/libdislin.a".
The "-l" is not part of the pathname that it can't find.
Why not,
"cannot find /usr/local/dislin/libdislin.a"?


Project options
Static linking: All ticked
Fortran flags: -I/usr/local/dislin/gf
Linker flags  : -L/usr/local/dislin/ -ldislin  -lGL  -lXm  -lXt  -lX11
==============================================================================
Generating Makefile... Okay
==============================================================================
Compiling /usr/local/dislin/examples/exa_f90.f90
Generating target
/usr/bin/ld: cannot find -lGL
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libXm.a(Xmos.o): In function `XmeGetHomeDirName':
(.text+0xa60): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libXm.a(Xmos.o): In function `XmeGetHomeDirName':
(.text+0xab0): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libX11.a(xim_trans.o): In function `_XimXTransSocketINETConnect':
(.text+0xcb0): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Error(E42): Last command making (target) returned a bad status
Error(E02): Make execution terminated

* Failed *

I don't understand why the "-lGL" flag is not working.
Why is it is failing to find GL (which I believe is the GLplot library)?
When I compile and link with the CLI, it finds GL.

---
John

Re: Struggling with DISLIN + GFortran under Raspbian

A few points:

1. The Makefile is always regenerated when a build is requested.  If "Build Before Launch" is enabled in the Launch options, it will cause the Makefile to be regenerated first.

2. How exactly did you set the environment variables?  Clearly Simply Fortran isn't aware of the environment variable specifying the location of DISLIN.  This problem is a  product of DISLIN's unconventional installation technique.  If you changed the environment variable in a terminal, it won't propagate to anywhere outside that terminal, similar to Windows.  If you set in a profile file, you'll need to logout and login again to have the environment variable affect your session.  You can always check if it has been set by opening a new terminal and seeing if DISLIN is set properly there.  Alternatively, you could symbolically link libdislin.so.10 to /usr/local/lib/libdislin.so.10.

3. You shouldn't have to use a "-l" in front of the full path for the DISLIN library.  Again, this configuration is a product of DISLIN's non-standard installation location.

4.  I'm not sure why your system can't find libGL on your system.  That seems mysterious.

The first solution did work, and you should probably stick with that one.  The only problem is that the DISLIN shared library is not being properly located on your system.  Again, you could just symbolically link the shared object to somewhere standard:

sudo ln -s /usr/local/dislin/libdislin.so.10 /usr/local/lib/libdislin.so.10

and then any DISLIN executable should be able to locate it.

Jeff Armstrong
Approximatrix, LLC

Re: Struggling with DISLIN + GFortran under Raspbian

After further research, I've learnt that
     LD_LIBRARY_PATH=/usr/local/dislin
     export LD_LIBRARY_PATH
cannot be used to set this particular environment variable.

It is necessary to do this:
     su
     [password]
     echo /usr/local/dislin >local.conf

Then reboot.
The system should then be able to run executables built with SF using DIslin, when linked to need Dislin's runtime .so file.

Also, to find out what library paths the system knows about:
     ldconfig -p

17 (edited by JohnWasilewski 2016-05-01 19:19:46)

Re: Struggling with DISLIN + GFortran under Raspbian

Copy of a message posted at Google Groups Dislin:

Dear Helmut,
I am extremely grateful to you for going to so much trouble to explain how to use Dislin in such detail. Your level of help and support are really fantastic.
Here's my progress report.  I am posting this in case others find it interesting, and not as a further request for more help from you, Helmut.

I have now successfully compiled, linked and executed your exa_f90 example using GFortran and Dislin on the Raspberry Pi 2 with Linux Raspbian.
I have done so,
(a) from the CLI, with the executable dependent on a Dislin shared library,
(b) using an IDE, with the executable dependent on a Dislin shared library,
(c) from the CLI, with the executable as a stand-alone program, needing no library support,
but not,
(d) using an IDE, with the executable as a stand-alone program, needing no library support.

The IDE I am using is the excellent Simply Fortran, from Approximatrix.com.

A difficulty I am now having with BOTH (c) and (d) (strangely, I am having this problem AFTER having successfully completed all three of (a) to (c) above) is that the linker is throwing up an error about being unable to do '-lGL' which I know is because it can't find the OpenGL library file libGL.a. 

I gave researched this and I've discovered that Raspbian does not yet fully support OpenGL.  It turns out that OpenGL support IS in fact included in the latest version of Raspbian, but only experimentally.  It has to be enabled using RasPi-config's 'Advanced' options.  When I first successfully built (c), I had not yet either discovered about OpenGL, or enabled it.  What I probably had just done is to install something connected with it, but I don't recall exactly what.

Since then, however, I've been unable to repeat (c).

I gave tried enabling OpenGL as above, but that only prevented the RPi from booting at all, so I had to edit config.txt from another laptop, to change back the two lines it altered, and I can't actually enable OpenGL at the moment.  Result I can no longer do (c), even though I HAVE, somehow,
I am going to wait patiently for OpenGL to be fully implemented in Raspbian, which I hope will be soon.  When that happens, I expect (c) and (d) will immediately work.

If anyone knows what I must have done to gain access to libGL.a from Raspbian just now, without enabling the experimental code, I'd love to know.
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

John

If dislin is working with the shared libraries, then you know that you already have the shared version of OpenGL on your machine or the program doesn't need that library at all.  Many of the "standard" libraries are only installed as shared libraries, and not the static versions.  For example, I would be surprised if you had the static version of the OpenMotif library on your machine as all of the versions of Linux I have used only distribute the shared version of libXm.  For some OS/architectures, static libraries are available for optional installation, but maybe not for the pi.

19 (edited by JohnWasilewski 2016-05-07 18:00:23)

Re: Struggling with DISLIN + GFortran under Raspbian

(1) I can now compile and build projects which make calls to DISLIN, but only as executables reliant on shared libraries.  I have been using the Dislin example, Exa_F90.for.  It produces an executable of around 43k.

(2) I cannot, yet, do the same, to produce stand-alone executables, although, see (5) below.

(3) It seems I am short of just one static library, without which, I cannot do (2).  The missing library is OpenGL.  Without this, Simply Fortran is throwing a build error  when linking the libraries.  The SF Linker flag, -lGL, produces an error message, "cannot fine libGL.a".

(4) Apparently, Raspbian does include OpenGL, but it is still experimental.  It is not accessible unless it has been enabled, with the Advanced tab of Raspbi-Config, which modifies /boot/config.txt. For me, it wrote the extra line,
dtoverlay=vc4-kms-v3d, and commented out my line, gpu_mem=256.  It also prevented my Pi from booting, so I had to edit /boot/config.txt on the SD card with another laptop to put it back to how it was.  I am hoping that OpenGL will be working fully before long.

See also:
http://www.linuxjournal.com/content/ras … gl-support
http://hackaday.com/2012/07/06/opengl-on-the-raspi/
https://benosteen.wordpress.com/2012/04 … x-windows/
https://www.raspberrypi.org/forums/view … p;t=138798

(5) Inexplicably and unrepeatably), I have once successfully done (2), with the Dislin example, Exa_F90.for.  It produced an executable of around 850k.
---
John

20 (edited by JohnWasilewski 2016-06-27 16:41:27)

Re: Struggling with DISLIN + GFortran under Raspbian

I am still having trouble persuading Simply Fortran to build an executable that calls DISLIN.
I know I have DISLIN correctly installed, because, using hte example supplied with the DISLIN package, source filnename exa_f90.f90,  these CLI commands work:

Compile only:   
      gfortran -c exa_f90.f90 -I/usr/local/dislin/gf

Link only:
      gfortran -o exa_f90 exa_f90.o -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

Compile-and-link:
      gfortran -o exa_f90 exa_f90.f90 -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

In SF, in order to do the same thing, there are five ways of telling the IDE how to feed the necessary information to the compiler and linker.  I know they can be used in different combinations, but the combination one picks has to be a correct one.

These are the possibilities:

1.  Explicitly add files to the project outline pane:
     I find it difficult to know which files to add, when trying to use eg DISLIN:
     (I'm never sure whether it should be libdislin.a, or dislin.mod, or dislin.f90)

2.  In Project options>Compiler flags>
     ..enter some compiler options

3.  In Project options>Compiler flags>
     ..enter some linker options

4.  In Project options>File locations>Search directories
     ..enter some Include/Module dirs search paths

5.  In Project options>File locations>Search directories
     ..enter some Library dirs search paths
     
On the face of it, the foregoing seems clear enough, and you'd think it would be easy to find a combination of settings that works, but somehow it always takes me forever to get it to work.

If I could think of a simpler and more intuitive way for the necessary settings to be entered into SF, I would do, but I can't.  I wish I could.

The problem is not helped by GFortran's quite poor documentation on how to use compiler options.  For example, nowhere can I find any explanation of the "-L dir" option. 

At the moment, I am still having no success even with the simple example I mentioned at the start of this post.  I am fairly sure that I have tried all settings that I'd expect to work.

eg (one of several)
1. In the project pane, add only the source file exa_f90.f90
3.  In Project options>Compiler flags>
     ..enter  -I/usr/local/dislin/gf ldislin
4. In Project options>File locations>Search directories
     ..enter -L/usr/local/dislin/

I'm not at home just now so I can't list what exactly I've tried that doesn't work, but I'll do so in a follow-up post to this one, today or tomorrow.
---
John

Re: Struggling with DISLIN + GFortran under Raspbian

John,

Whenever linking, you should have the flags:

-L/usr/local/dislin/ -ldislin

I don't know why it would work without the dash before "ldislin," but it shouldn't.  The "-L" flag tells the linker to look in the specified directory for libraries.  The "-l" flag tells the linker to use a library, preceded by the prefix "lib," to be linked wherever the linker can find it.

There are a few problems that I can see with your input in Simply Fortran's options. First, start with a clean project; don't leave any flags in the Compiler Flags tab or the Search Directories.  Next, in Project options>File locations>Search directories, add the following exactly:

   In Module/Include Files, add exactly:   /usr/local/dislin/gf

   In Libraries, add exactly: /usr/local/dislin

Notice that there are no "-L" or "-I" flags in either of the above.  Simply Fortran adds these internally since this window is used for adding actual directories.

Then, returning to Project Options, navigate to the Compiler Flags and add to the Linker box:

-ldislin

The flag above says to "link with libdislin.a wherever it might be."  It should be able to locate the library since you've provided a directory to search, "/usr/local/dislin," in the previous step.

These changes should allow the program to compile.

If you are having trouble with these changes still, post your Makefile here.  I'm guessing a flag might still be wrong.

EDIT: I made a minor mistake in the Search Directories descriptions.  It should be correct now.

Jeff Armstrong
Approximatrix, LLC

22 (edited by JohnWasilewski 2016-06-27 16:46:46)

Re: Struggling with DISLIN + GFortran under Raspbian

I am extremely sorry.
The CLI compile and link commands DO have a dash before the last option.

I copied it down wrongly.
IDIOT!

I've corrected the post.  The remainder, well, remains.
I'll read through your reply now Jeff.
---
J.

23 (edited by JohnWasilewski 2016-06-27 17:17:06)

Re: Struggling with DISLIN + GFortran under Raspbian

I'm fairly sure I have tried what you advise, Jeff.
I follow completely why those are the correct settings.

Anyway, I've tried again.

My CLI command (copied and pasted to prevent more mistakes) was:
sudo gfortran -o egCLI exa_f90.f90 -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin
It produces an executable, egCLI, of 47.2kB
CLI command ./egCLI then runs this executable successfully.

For the SF version :

Project pane
Only the program source file.

Project options
   General tab
   Target name = egSF
    Linker tab
   Static linking
      - All static selected
      - Build import library selected
   Compiler flags tab
   Linker option: -ldislin
   File locations tab
      - Search directories:
        Modules/include files: /usr/local/dislin/gf
        Libraries: /usr/local/dislin

CLEAN
Deleting build/exa_f90.o and related files
Deleting egSF

* Complete *

BUILD
=====================================
Generating Makefile... Okay
=====================================
Compiling /usr/local/dislin/examples/exa_f90.f90
Generating egSF
/usr/local/dislin/libdislin.a(disini.o): In function `qqgglb':
dis_unx.c:(.text+0x56dc): undefined reference to `pthread_self'
/usr/local/dislin/libdislin.a(disini.o): In function `qqsglb':
dis_unx.c:(.text+0x5778): undefined reference to `pthread_self'
dis_unx.c:(.text+0x5914): undefined reference to `pthread_mutex_init'
dis_unx.c:(.text+0x59b8): undefined reference to `pthread_mutex_lock'
dis_unx.c:(.text+0x5a0c): undefined reference to ...
:
:
. . .[MANY] . . .
:
:
. . . . . . . . . : undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/arm-linux-gnueabihf/4.9/libgfortran.a(random.o): In function `_gfortran_random_seed_i8':
(.text._gfortrani_random_seed_i8+0x20): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/arm-linux-gnueabihf/4.9/libgfortran.a(random.o): In function `_gfortran_random_seed_i8':
(.text._gfortrani_random_seed_i8+0x140): undefined reference to `pthread_mutex_unlock'
collect2: error: ld returned 1 exit status
Error(E42): Last command making (egSF) returned a bad status
Error(E02): Make execution terminated

* Failed *

I'll past the MAKEfile in another post straight after this.
---
John

24 (edited by JohnWasilewski 2016-06-27 17:26:08)

Re: Struggling with DISLIN + GFortran under Raspbian

#
# Automagically generated by Approximatrix Simply Fortran 2.28
#
FC="gfortran"
CC="gcc"
AR="ar"
WRC="windres"
RM=rm -f

IDIR=-I/usr/local/dislin/gf

LDIR=-L/usr/local/dislin


OPTFLAGS= -g

SPECIALFLAGS=$(IDIR)

RCFLAGS=-O coff

PRJ_FFLAGS=

PRJ_CFLAGS=

PRJ_LFLAGS=-ldislin

FFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(PRJ_FFLAGS) -Jmodules

CFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(PRJ_CFLAGS)

"build/exa_f90.o": "../Exa_f90/exa_f90.f90"
    @echo Compiling ../Exa_f90/exa_f90.f90
    @$(FC) -c -o "build/exa_f90.o" $(FFLAGS) "../Exa_f90/exa_f90.f90"

clean: .SYMBOLIC
    @echo Deleting build/exa_f90.o and related files
    @$(RM) "build/exa_f90.o"
    @echo Deleting egSF
    @$(RM) "egSF"

"egSF":  "build/exa_f90.o" "build/exa_f90.prj.target"
    @echo Generating egSF
    @$(FC) -o "egSF" -static "build/exa_f90.o" $(LDIR) $(PRJ_LFLAGS)

all: "egSF" .SYMBOLIC

25 (edited by JohnWasilewski 2016-06-27 17:27:12)

Re: Struggling with DISLIN + GFortran under Raspbian

I've noticed in the makefile that my SF version pulls in the source file from a different directory, whereas in the CLI version, I compile the copy of the source file placed there.
I've just changed this in the SF version to use the local source file. 
As expected, it makes no difference.

I've edited the makefile post (previous post) to this corrected version.
---
J