Install DISLIN 11.3 on Ubuntu 20.04 Focal Fossa
DISLIN is a very nice and well-documented 2-D and 3-D plotting framework for Fortran and some other programming languages. Furthermore DISLIN provides some widgets to create simple graphic user interfaces (GUIs).
This how-to describes how to install DISLIN 11.3 on Ubuntu 20.04 (Focal Fossa) and how to compile and link a sample Fortran 90 program with GUI against the shared and static DISLIN libraries.
This how-to should work on Ubuntu-related distributions as Linux Mint, etc.
In this how-to Gfortran is used as the standard Fortran 90 compiler of GNU/Linux. A new thing in Ubuntu 20.04 is the absent 32-bit version. So I just cover a 64-bit installation.
Installation
Install Motif libraries
DISLIN needs the Motif libraries for the GUI widgets and tools. But Motif is not installed on Ubuntu by default.
Focal Fossa has the Version 4 libraries of Openmotif in its universe repository which work with DISLIN 11.3. Ensure that you have Internet access and install Motif packages:
sudo apt install libmotif-common libmotif-dev
In general multiverse/universe repositories should be activated in Focal but if you get an error therfore here, activate it as described as followed. Write in one line in the terminal:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` universe multiverse'Take care of the back tics (`): You find the `-key to the left of the key “1” on the standard English keyboard. The `lsb_release -sc` makes this command independent of the Ubuntu version.
And then:
sudo apt updateAfter repeat Motif installation.
Install compiler
This how-to uses Fortan. The GNU Fortran compiler Gfortran is in the repositories of Ubuntu. Install it right away:
sudo apt install gfortran
It is not required for compiling DISLIN-applications but recommended to install the meta-package “build-essential” as well. It contains commands like make, configure, etc.
If you want to use another supported language you can install it instead of Gfortran. For the differences refer Test Installations for DISLIN and Linux for details.
Download and install DISLIN
- Download the appropriate deb file
to your e.g. downloads directory (~/Downloads). For Ubuntu (64-bit) download from ftp://ftp.gwdg.de/pub/grafik/dislin/linux/i586_64/ the “dislin-11.3.linux.i586_64.deb” file. - Installation:
sudo dpkg -i ~/Downloads/dislin-11.3.linux.i586_64.deb
- DISLIN is now installed in “/usr/local/” in the directory “dislin/“. Dependent on your Fortran compiler version you may need to recompile the MODULE files “dislin.f90” in “/usr/local/dislin/” (for Gfortran: /usr/local/dislin/gf/). For Gfortran:
cd /usr/local/dislin/gf/ sudo gfortran -c dislin.f90 cd real64 sudo gfortran -c dislin.f90
Build programs against the shared DISLIN library
The DISLIN way via gf95link script
To get started have a look at “/usr/local/dislin/README“. To compile the sample program map_f90, copy the source file to your home directory, move to home and compile/link it with “gf95link“:
cp /usr/local/dislin/examples/map_f90.f90 ~ cd ~ gf95link -a map_f90
You can compile all single precision programs the same way.
Run map_f90 by typing
./map_f90
in the terminal.
Link your program with the double precision DISLIN library, if your program uses double precision reals (map_f90 does not), by adding the -r8 option:
gf95link -a -r8 doubleprec-app
Note: Take care that you do not append the filename suffix – e.g. “.f90” – to the filename when you use gf95link or the other compile scripts provided by DISLIN.
If you installed another compiler use the appropriate script, e.g. clink instead of gf95link for C.
Note: Unfortunately you cannot run your app from the file manager when you built it with gf95link (but from the terminal). Use the “The classic way” below to add this capability.
The classic way
If you want to compile/link your program the classic way or to integrate DISLIN to your IDE and if you want to run it from your file manager, you call DISLIN via “-ldislin“, the necessary “dislin.mod” file is located in “/usr/local/dislin/gf/” for single precision. For double precision use “-ldislin_d” and find the mod-file in “/usr/local/gf/real64/“:
gfortran map_f90.f90 -no-pie -I/usr/local/dislin/gf -ldislin -o map_f90
or for double precision:
gfortran doubleprec-app.f90 -no-pie -I/usr/local/dislin/gf/real64 -ldislin_d -o doubleprec-app
Change “doubleprec-app.f90” to the real file/app name. The compiler and linker options are explained in the next chapter.
Run map_f90 by typing
./map_f90
in the terminal or double-click the file in your file manager:
In both cases your app is dependent on a gfortran and DISLIN installation on target machines.
Drawbacks of shared linking
“gf95link” and linking via “-ldislin(_d)” links the shared DISLIN library to your program. That reduces the footprint of your application on your hard disk. However if you intend to run this program on other machines, you have to install DISLIN on these machines, too. It is also depended on a gfortran installation on these machines.
To avoid both issues go to the next chapter and build your program statically instead.
Build programs against the static DISLIN library
To build your DISLIN app against the static DISLIN library you have to install missing X11-libraries:
sudo apt install libx11-dev libxt-dev libgl1-mesa-dev
For compiling and static linking type for map_f90 (and for other single precision apps):
gfortran map_f90.f90 -static-libgfortran -no-pie -I/usr/local/dislin/gf /usr/local/dislin/libdislin.a -lXm -lXt -lX11 -lGL -o map_f90
If you use double precision real variables, type:
gfortran doubleprec-app.f90 -static-libgfortran -no-pie -I/usr/local/dislin/gf/real64 /usr/local/dislin/libdislin_d.a -lXm -lXt -lX11 -lGL -o doubleprec-app
instead.The options are described below:
-static-libgfortran | Links the static gfortran library to the app rather than the shared one (default) and makes it independent of a gfortran installation on the target machines. |
-no-pie |
Solves the problem that the file manager misinterprets the executable as a shared library (see below). Otherwise it prevents it from running from your file manager. |
-I | Path to the module files |
/usr/local/dislin/libdislin(_d).a | Links the static DISLIN library instead of the shared one, when using -ldislin(_d). Target machines do not need DISLIN installed. |
-lXm -lXt -lX11 -lGL | Links the shared Modif libraries (static ones are not provided). Still Motif 4 dependency left. |
-o | Specify the file name of the app (here map_f90). Without this option your binary is named a.out |
Now you can start your GUI-program from your file manager or terminal. Furthermore you can copy it to any other machines without DISLIN and Gfortran installed. But you still need the Motif4 libraries and some other libraries. Install packages libxm4 and libquadmath0 on these machines.
The -static option would normally solve that but some Motif libraries are not provided in a static form, so this option fails in this case.
But they are still some issues left which we take care of in the next chapter.
Distribution-independent DISLIN applications?
For a long time it was complicated to provide distribution-independent applications in GNU/Linux. In Ubuntu it was no different, of course.
There were several problems:
- The Motif libraries depend on a lot of XServer libraries (libXm, libXt, etc.) which are not all provided in a static form (.a-libs) or depend themselves on other libraries. That means it is not possible to link statically against Motif out-of-the-box.
- Furthermore if you use the map capability of DISLIN in your app the maps will not be displayed on target machines even when you built it statically. They are not stored in the library file.
- Additionally there is a dependency to the libquadmath0-package.
- When run your app on older distros you may get glibc-version problems.
You may work around a bit following the suggestion of E.T. at Stack Overflow: “Just build on the system with the oldest GLIBC you still want to support.”
As far as I know Ubuntu provides Motif 4 in the universe repository since Natty Narwhal (11.04).You may run this Ubuntu version in a virtualization environment just for compiling/linking. That means your app will work from Ubuntu 11.04 onwards.
For an Only-Ubuntu-package you just have the package dependencies of libxm4 and libquadmath0, as long as you do not make use of the map capabilities of DISLIN.
But in newer Ubuntu versions you may use Snap or Flatpak or AppImages to package distribution-independent packages. This may solve all the problem regarding distribution dependencies but I have not tried it yet.
Troubleshooting
“No application installed for shared library”
Newer gfortran versions uses -fPIC as default. This causes the file manager to interpret the binary as a shared library instead of an executable and you are not able to run your app from the file manager (but from the terminal). You get the error:
“Could Not Display xxx. There is no application installed for “shared library” files. Do you want to search for an application to open this file?”
To avid this use the link option -no-pie as described above.
“Error while loading shared libraries”
If you get an error while linking against the shared library, like:
“error while loading shared libraries: libdislin.so.11: cannot open shared object file: No such file or directory”
you have to specify the environment variable “LD_LIBRARY_PATH” to make DISLIN find its shared libraries. On current supportet Ubuntus you should not see this error.
However, for a system-wide setup start a text editor (here “nano”) with root privileges and open the file bash.bashrc. Open a terminal and type:
sudo nano /etc/bash.bashrc
and append the following lines:
LD_LIBRARY_PATH=/usr/local/dislin export LD_LIBRARY_PATH
Save bash.bashrc. You just need to restart your terminal (window).
For a single user setup just do this in ~/.bashrc in your home directory instead of /etc/bash.bashrc.
Acknowledgment
Thanks to Helmut Michels, the author of DISLIN, for his assistance. He helped me out in this version, too. Great support. If you have any question regarding DISLIN go to dislin-users in Google Groups. He is around there.
Related Links
- DISLIN Homepage
- Test Installations for DISLIN and Linux – DISLIN Homepage
- Google Group dislin-users
- Using DISLIN to make a GUI – Dr. Clive Page (University of Leicester)
- German Wikibooks for DISLIN
- Install DISLIN 10.6 on Ubuntu 16.04 Xenial Xerus – Hanis’s Omnium Gatherum
- Install DISLIN 10.4 on Ubuntu 14.04 Trusty Tahr – Hanis’s Omnium Gatherum
Pingback: (English) Install DISLIN 10.6 on Ubuntu 16.04 Xenial Xerus | Hanis Sammelsurium