Install libg2c.so.0 for ZDOCK in Debian 11

Page content

While using ZDOCK in Debian 11, an error message shew:

$ ./mark_sur
./mark_sur: error while loading shared libraries: libg2c.so.0: cannot open shared object file: No such file or directory

libg2c is one of the components of the g77 in gcc version 3.4.x:

g77 consists of several components:

  • The libg2c run-time library. This library contains the machine code needed to support capabilities of the Fortran language that are not directly provided by the machine code generated by the g77 compilation phase.

    libg2c is just the unique name g77 gives to its version of libf2c to distinguish it from any copy of libf2c installed from f2c (or versions of g77 that built libf2c under that same name) on the system.

But in current Debian 11/bullseye, the g77 has been replaced by the package gfortran and no libg2c.so.0 available.

The way to solve this problem is to download the libf2c package from https://rpm.pbone.net, then extract the package, and copy the libg2c.so.0 file to local library directory.

1. Download rpm packages:

2. Unpack rpm package:

Note:

Install rpm2cpio package if necessary:

$ sudo apt update
$ sudo apt install rpm2cpio
$ rpm2cpio libf2c-3.4.4-2.fc3.x86_64.rpm | cpio -idmv

It creates a usr/ directory in the current directory, the contents:

$ tree usr/
usr/
└── lib64
    ├── libg2c.so.0 -> libg2c.so.0.0.0
    └── libg2c.so.0.0.0

3. Copy libf2c.so.0 to library diretory:

In my computer, the local library directory is: $HOME/lib

$ cp usr/lib64/libf2c.so.0 $HOME/lib

Then edit ~/.bashrc file, append this line:

export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH

Reload the environment by

$ source ~/.bashrc

or simply logout then login, the mark_sur works.

Reference

  1. error while loading shared libraries: libg2c.so.0: cannot open shared object的解决办法
  2. What is GNU Fortran?