Can octave compile Fortran mex-files?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can octave compile Fortran mex-files?

Lukas Reichlin-2
Dear Octave Community

I'm trying to compile a mex-file written in Fortran. It is called muHopt.f and can be found here [1].

Using makefile_dksyn.m, which consists of the following code …

mex muHopt.f \
    SB10AD.f SB10MD.f AB05MD.f AB07ND.f AB04MD.f \
    SB10PD.f SB10QD.f SB10RD.f SB10LD.f select.f \
    TB05AD.f AB13MD.f SB10YD.f MB01RX.f MB01RU.f \
    SB02RD.f MA02AD.f MB02SZ.f MB02TZ.f MB02RZ.f \
    DG01MD.f SB10ZP.f SB02MS.f MA02ED.f SB02RU.f \
    SB02SD.f SB02QD.f SB02MV.f SB02MW.f SB02MR.f \
    MB02PD.f MB01SD.f MC01PD.f TD04AD.f MB01UD.f \
    SB03SY.f SB03MX.f SB03SX.f MB01RY.f SB03QY.f \
    SB03QX.f SB03MY.f TD03AY.f TB01PD.f TB01XD.f \
    SB04PX.f SB03MV.f SB03MW.f AB07MD.f TB01UD.f \
    TB01ID.f MB01PD.f MB03OY.f MB01QD.f \
    "$(mkoctfile -p LAPACK_LIBS)" \
    "$(mkoctfile -p BLAS_LIBS)" \
    "$(mkoctfile -p FLIBS)"


… I get a couple of errors:

octave:2> makefile_dksyn
Undefined symbols for architecture x86_64:
  "_mxgetm_", referenced from:
      _mexfunction_ in muHopt.o
  "_mexerrmsgtxt_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxgetpr_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxcopyptrtoreal8_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxisnumeric_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxiscomplex_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxgetn_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxcreatedoublematrix_", referenced from:
      _mexfunction_ in muHopt.o
  "_mxcopyreal8toptr_", referenced from:
      _mexfunction_ in muHopt.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
octave:3>

Now my question is: Does Octave come with these functions? How can I include them? Do I have to write a C++ oct-file, rewrite the muHopt.f function and include it with extern "C"?

Thanks in advance for any insights.
Lukas


[1]
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/extra/control-devel/devel/dksyn/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Can octave compile Fortran mex-files?

bpabbott
Administrator

On Mar 5, 2012, at 10:27 AM, Lukas Reichlin wrote:

> Dear Octave Community
>
> I'm trying to compile a mex-file written in Fortran. It is called muHopt.f and can be found here [1].
>
> Using makefile_dksyn.m, which consists of the following code …
>
> mex muHopt.f \
>    SB10AD.f SB10MD.f AB05MD.f AB07ND.f AB04MD.f \
>    SB10PD.f SB10QD.f SB10RD.f SB10LD.f select.f \
>    TB05AD.f AB13MD.f SB10YD.f MB01RX.f MB01RU.f \
>    SB02RD.f MA02AD.f MB02SZ.f MB02TZ.f MB02RZ.f \
>    DG01MD.f SB10ZP.f SB02MS.f MA02ED.f SB02RU.f \
>    SB02SD.f SB02QD.f SB02MV.f SB02MW.f SB02MR.f \
>    MB02PD.f MB01SD.f MC01PD.f TD04AD.f MB01UD.f \
>    SB03SY.f SB03MX.f SB03SX.f MB01RY.f SB03QY.f \
>    SB03QX.f SB03MY.f TD03AY.f TB01PD.f TB01XD.f \
>    SB04PX.f SB03MV.f SB03MW.f AB07MD.f TB01UD.f \
>    TB01ID.f MB01PD.f MB03OY.f MB01QD.f \
>    "$(mkoctfile -p LAPACK_LIBS)" \
>    "$(mkoctfile -p BLAS_LIBS)" \
>    "$(mkoctfile -p FLIBS)"
>
> … I get a couple of errors:
>
> octave:2> makefile_dksyn
> Undefined symbols for architecture x86_64:
>  "_mxgetm_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mexerrmsgtxt_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxgetpr_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxcopyptrtoreal8_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxisnumeric_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxiscomplex_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxgetn_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxcreatedoublematrix_", referenced from:
>      _mexfunction_ in muHopt.o
>  "_mxcopyreal8toptr_", referenced from:
>      _mexfunction_ in muHopt.o
> ld: symbol(s) not found for architecture x86_64
> collect2: ld returned 1 exit status
> octave:3>
>
> Now my question is: Does Octave come with these functions? How can I include them? Do I have to write a C++ oct-file, rewrite the muHopt.f function and include it with extern "C"?
>
> Thanks in advance for any insights.
> Lukas


It should be possible to write a c/c++ interface module using f2003.

I had looked at this several years ago, but never got around to it.

You can get an idea of what needs to be done by looking at the work below.

        http://www.mathworks.com/matlabcentral/fileexchange/25934-fortran-95-interface-to-matlab-api-with-extras

Ben



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave