12

I am getting the following error when I trying to a run mex file in MATLAB:

??? Invalid MEX-file
'findimps3.mexa64':
/MATLAB/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/libblas.so.3gf)

Any ideas how to solve this problem?

update: I found out that "strings MATLAB/.../libgfortran.so.3 | grep GFORTRAN" output GFORTRAN_1.0. I tried to changed libgfortran inside MATLAB but it didn't work. Not I think it's better to find a suitable libblas that works with GFORTRAN_1.0.

Mohammad Moghimi
  • 4,636
  • 14
  • 50
  • 76

5 Answers5

13

read this link, it explains how to configure matlab on some linux systems.

here the steps that are relevant to you:

To enable running external programs, […] fortran libraries need to be properly updated and linked. Look at the output of this command:

ll "$MATLABDIR/bin/glnxa64/"

It is likely that [this link] exist:

libgfortran.so.3 -> libgfortran.so.3.0.0

Search for [this library] on your machine:

locate libgfortran.so

[…] Update Matlab's links to point to these newer versions:

sudo ln -sf [location of libgfortran.so.3.0.0] "$MATLABDIR/bin/glnxa64/libgfortran.so.3"
flying sheep
  • 8,475
  • 5
  • 56
  • 73
  • [this link](http://judsonsnotes.com/notes/index.php?option=com_content&view=article&id=659:installing-matlab-in-ubuntu-1110&catid=37:tech-notes&Itemid=59) gives Error 502. Good that you repeated the necessary steps here. In my case, `libgfortran.so.3` is not present on my system (Fedora 30), only `libgfortran.so.1` and `libgfortran.so.5`. But I guess that should go into a new question. – winkmal Jul 19 '19 at 16:18
3

I (think I) fixed this problem by running matlab with LD_PRELOAD, like this

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libfreetype.so:/usr/lib/x86_64-linux-gnu/libgfortran.so.3 matlab

Notice freetype was another library I was having a similar problem with.

dividebyzero
  • 2,190
  • 1
  • 21
  • 33
  • Note that if you don't have permission to edit `$MATLABDIR/bin` this may be your only choice. Seems to work for me. – pattivacek Oct 14 '13 at 20:22
2

In my case the following command worked:

sudo ln -sf /usr/lib/gcc/i686-linux-gnu/4.7/libgfortran.so /usr/local/MATLAB/R2012a/sys/os/glnx86/libgfortran.so.3

Matlab was complaining it couldn't find the GFORTRAN1.4 in the following location:

/usr/lib/gcc/i686-linux-gnu/4.7/libgfortran.so

So I linked this location to the library I had :

/usr/local/MATLAB/R2012a/sys/os/glnx86/libgfortran.so.3

I found the location of this library by using the locate command as given above:) Thanks for the help:)

Ankur
  • 5,086
  • 19
  • 37
  • 62
0

In my case, fixed by
$ ln -sf /usr/lib64/libgfortran.so.3.0.0 /opt/matlab/sys/os/glnxa64/libgfortran.so.3

Errors I meet when using CDSP:
csdp: /opt/matlab/sys/os/glnxa64/libgfortran.so.3: version GFORTRAN_1.4' not found (required by /usr/lib64/atlas/libptf77blas.so.3)
csdp: /opt/matlab/sys/os/glnxa64/libgfortran.so.3: version
GFORTRAN_1.4' not found (required by /usr/lib64/atlas/libf77blas.so.3)

ying17zi
  • 492
  • 6
  • 15
0

I just ran into the same problem (error usr/lib64/libgfortran.so.3: version `gfortran_1.4' not found) and it was actually not hard to fix. The problem seems to be that gfortran_1.4 version of libgfortran.so.3 comes from the release gcc-4.6.2 (i.e. fortran 4.6).

What I did was downloaded gcc-4.6.2 and built, using the steps: tar -xvf gcc-4.6.2.tar.gz cd gcc-4.6.2 ./contrib/download_prerequisites cd .. mkdir objdir cd objdir $PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 --enable-languages=c,fortran,c++,go make make install

Then, once everything was made, I went to the directory where the new, fresh libgfortran.so.3 was sitting (in my case it was /home/testuser/objdir/x86_64-unknown-linux-gnu/32/libgfortran/.libs/)

I copied this version of libgfortran.so.3, and went to the directory where my program was expecting to find libgfortran.so.3. I replaced the old one (the old libgfortran.so.3) with the new one (the one we just copied).

The problem instantly went away. I hope this helps you too!