0
votes

I'm trying to create mex for matlab from some cpp and fortran files. They all compile well and creates the .obj file. But during linking I get the error lg2c not found.

I have matlab 2007 installed in win vista. I also have mingw and gnumex installed. The mex -setup in matlab returns 2 compilers lcc and VS 2003

I'm using G77 fortran compiler Followed instructions in http://www.cs.ubc.ca/~pcarbo/Compile_LBFGSB_on_Windows.txt

1
What Fortran compiler are you using ? - High Performance Mark
And can you find g2c on your system ? - High Performance Mark
I cannot find g2c in my system. - Nripun
I'm using gcc 4.5. I read somewhere that g2c is not part of version 4 and higher. Is it possible to find an installer for gcc 3.4.5? - Nripun
If you're using gcc 4.5 you should use gfortran instead of g77. - janneb

1 Answers

0
votes

Fortran programs compiled with g77 (as provided by GCC <= 3.4.6) need to link with libg2c. Fortran programs compiled with gfortran (as provided by GCC >= 4.0.0) need to link with libgfortran. In any case, the compiler driver (whether g77 or gfortran) ought to do that for you.

Now, the question is: is there a reference to libg2c in the Matlab-provided files. If so, you have no choice but to provide libg2c. You can find a download there.