What Is Libg2C Library

What is libg2c library?

What is GNU Fortran?

g77 consists of several components:

  • A modified version of the gcc command, which also might be installed as the system's cc command. (In many cases, cc refers to the system's “native” C compiler, which might be a non-GNU compiler, or an older version of gcc considered more stable or that is used to build the operating system kernel.)

  • The g77 command itself, which also might be installed as the system's f77 command.

  • 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.

You may think of it as, libg2c is to g77 as libc is to gcc.

Note that as of the GCC 4.x series, g77 has been discontinued, replaced by gfortran, which produces programs that do not require an extra libg2c runtime library.

compiling fortran 77 code with ifort : libg2c missing

libg2c is a library used by the obsolete g77 compiler. If the reference is in a makefile you found, just remove it. The "ifort" command should be able to provide the necessary libraries.

How to find out which compiler was used: g77 or gfortran

nm filename | fgrep ' __g77'

will give results if g77 was used, meanwhile

nm filename | fgrep '@@GFORTRAN'

will give results if gfortran is used.

Linker errors with Fortran to C library - /usr/lib/libf2c.so: undefined reference to 'MAIN__'

You should have paid closer attention to the first error message. The linker is telling you that no symbol MAIN__ can be found, which is what f2c is expected that the fortran main will be compiled to in your C or C++ code somewhere. The f2c library itself was working just fine.

The solution to the original error would be to make sure the correct entry point is defined in your code. It might be that by using C++ to compile, you have name mangling problems and the correct entry point for the f2c library doesn't exist.

Now by messing around with the f2c libraries, you have totally broken your f2c installation. Reinstall it and start again...

Trying to install PostStat, a library to add statistics function into Postgres

change -lg2c by -lf2c

Add to poststat.c , at the end

int MAIN__(){
return (0);
}

Trying to install PostStat, a library to add statistics function into Postgres

change -lg2c by -lf2c

Add to poststat.c , at the end

int MAIN__(){
return (0);
}

Determine which compiler built my LAPACK

From the same INSTALL file you referenced...

How to check the ABI of blas/lapack/atlas
-----------------------------------------

One relatively simple and reliable way to check for the compiler used to build
a library is to use ldd on the library. If libg2c.so is a dependency, this
means that g77 has been used. If libgfortran.so is a a dependency, gfortran has
been used. If both are dependencies, this means both have been used, which is
almost always a very bad idea.

If I had to guess, I would probably guess gfortran also as the only two free fortran compilers that I know of are g77 and gfortran and g77 development is pretty much dead as far as I know ... Another thing to check is g77 (by default) appended two underscores to symbols whereas gfortran (by default) only appends one. This is probably the thing that is most important for numpy to know ... although there may be other subtle differences (if numpy is doing some dirty hacking to get at information stored in a common block for instance).



Related Topics



Leave a reply



Submit