Rune Allnor <firstname.lastname@example.org> wrote in message <email@example.com>... > On 8 Okt, 16:37, "Michele Catalano" <cata...@yahoo.it> wrote: > > Dear All, > > > > I'm trying to link matlab and fortran with mex files and engine matlab, in linux OS. My general purpose is the following: > > > > 1) a matlab script A calls a mex function B based upon fortran source code > > > > 2) mex function B calls another function in matlab C within matlab engine > > > > 3) matlab routine C calls another mex file in fortran D > > > > While i'm able to do steps 2) and 3), I can't do step 1). Before to show the code, please reply to this simple question: > > > > Is it possible to build the overall process 1-3? > > I don't know if it is possible to do *all* of the above, > but step 1) is trivial when the MEX function is 'simple'. > And works correctly. > > To investigate what is going on, make some trivial functions > A - D above, that only print some messages to the command line, > like "Entering A - Calling B" at the entry point, and > "Returned from B - Exiting A" as the last statement before > return. > > This way you isolate the linking process from any problems > caused by the business code. If you can get such a simple > example to behave as expected, then the overall idea works. > > Apart from that, please post any error messages that appeared > when you tried to compile the program. > > Rune
It follows the command and the error:
mex '-f' /home/catalanom/Scrivania/provaF/engopts.sh FortranChiamaMatlabSubII.F90 /usr/lib/gcc/i486-linux-gnu/4.2.4/libgfortranbegin.a(fmain.o): In function `main': (.text+0x23): undefined reference to `MAIN__' collect2: ld returned 1 exit status
mex: link of 'FortranChiamaMatlabSubII' failed.
??? Error using ==> mex Unable to complete successfully
It seems it asks a main program for the function A, while I have to set it as a subroutine mexfunction()