Hi all,
I am new to R OMS and MATLAB. After a long struggle, I still can’t solve RNT mex_compile problem when I try to mex the fortran codes in ‘matlib/rnt/’directory . So I have to turn to your help!!
The system I am using windows(32bit), and Matlab version is R14sp3.
I’ve downloaded RNT from http://www.o3d.org/ and Arango’s matlab tree as well, however, these two sources both have no mex-file with extension of mexw32, so I have to recompile the fortran code on my own PC.
According to the mex_compile instruction in http://www.o3d.org/ (unfortunately, it is for linux system, but mine is windows, so I am not sure if this is the problem), I downloaded and installed g95-MinGW. By the way, I also prepared mingw-get-inst-20101030 and gnumex to setup g95-MinGW in matlab.
After these works, I open matlab and go to /gnumex directory, input gnumex to setup g95 path and mingw path and select fortran compile option.
After this, I check the setup by input mex -v, and have the following output:
>> mex -v
This is mex, Copyright 1984-2005 The MathWorks, Inc.
->Default options filename found in C:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3
----------------------------------------------------------------
->Options file= C:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
MATLAB = E:\roms\PROGRA~1\MATLAB
-> COMPILER = g95
-> Compiler flags:
COMPFLAGS = -c -DMATLAB_MEX_FILE -fcase-upper -mrtd -fno-underscoring
OPTIMFLAGS = -O3
DEBUGFLAGS = -g
arguments =
Name switch = -o
-> Pre-linking commands =
-> LINKER = E:\roms\PROGRA~1\MATLAB\sys\perl\win32\bin\perl.exe e:\roms\backup\software\gnumex\linkmex.pl
-> Link directives:
LINKFLAGS=-LC:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\gnumex
LINKDEBUGFLAGS = -g -Wl,--image-base,0x28000000\n
LINKFLAGSPOST =
Name directive = -o .mexw32
File link directive =
Lib. link directive =
Rsp file indicator =
-> Resource Compiler = E:\roms\PROGRA~1\MATLAB\sys\perl\win32\bin\perl.exe e:\roms\backup\software\gnumex\rccompile.pl -o mexversion.res
-> Resource Linker =
----------------------------------------------------------------
Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
or (to build an Ada S-function):
MEX [-v] [-g] -ada <sfcn>.ads
Use the -help option for more information, or consult the MATLAB API Guide.
E:\ROMS\PROGRAM FILES\MATLAB\BIN\MEX.PL: Error: No file names given.
??? Error using ==> mex
Unable to complete successfully
I think it’s OK, then I start to mex.
First is testing mex under E:\roms\Program Files\MATLAB\extern\examples\mex directory.
I input mex yprimef.F(sometime is ‘mex yprime.F’ for testing, but I found there is no yprime.F file but only the yprimef.F ), but it goes wrong as follows:
>> mex yprimef.F
g95: C:\Users\lokky\Application: No such file or directory
g95: Data\MathWorks\MATLAB\R14SP3\gnumex\fmex.def: No such file or directory
g95: Data\MathWorks\MATLAB\R14SP3\gnumex: No such file or directory
link command: g95 -shared C:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\gnumex\fmex.def -o yprimef.mexw32 -LC:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\gnumex -s C:\Users\lokky\AppData\Local\Temp\yprimef.obj -lflibmx -lflibmex -lflibmat
E:\ROMS\PROGRAM FILES\MATLAB\BIN\MEX.PL: Error: Link of 'yprimef.mexw32' failed.
??? Error using ==> mex
Unable to complete successfully
But I still go on trying to mex the fortran files in the 'matlib/rnt/' directory (Each .F file's beginning section has been changed for my 32bit system as in the instruction in advance). It’s very strange that I can mex some fortran files (rnt_2s_mex.f, rnt_2sigma_mex.f, rnt_2z_mex.f, rnt_2z_mex_linux.f, rnt_fill_mex.f, rnt_hindicesTRI_mex.f, rnt_rho_eos_mex.f0) successfully to get mex files like rnt_hindicesTRI_mex.mexw32, but the others (rnt_fill3ab_mex.f, rnt_fill_time_mex.f, rnt_fillab_mex.f, rnt_oa2d_mex.f, rnt_oa3d_mex.f, rnt_oa3d_v2_mex.f) got the similar error information as the testing mex:
>> mex rnt_fillab_mex.f
In file rnt_fillab_mex.f:350
call inverse(Gp,c,c,A,issing) ! compute A=inv(Gp)
1
In file rnt_fillab_mex.f:369
subroutine inverse(A,r,c,Inv,issing)
2
Warning (155): Inconsistent types (INTEGER(4)/REAL(8)) in actual argument lists at (1) and (2)
In file rnt_fillab_mex.f:41
call oa_ex(%val(x), %val(y),%val(datain),
1
In file rnt_fillab_mex.f:51
subroutine oa_ex(x,y,datain,xhat,yhat,PtIn,PtOut,dataout,
2
Warning (155): Inconsistent types (INTEGER(4)/REAL(8)) in actual argument lists at (1) and (2)
g95: C:\Users\lokky\Application: No such file or directory
g95: Data\MathWorks\MATLAB\R14SP3\gnumex\fmex.def: No such file or directory
g95: Data\MathWorks\MATLAB\R14SP3\gnumex: No such file or directory
link command: g95 -shared C:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\gnumex\fmex.def -o rnt_fillab_mex.mexw32 -LC:\Users\lokky\Application Data\MathWorks\MATLAB\R14SP3\gnumex -s C:\Users\lokky\AppData\Local\Temp\rnt_fillab_mex.obj -lflibmx -lflibmex -lflibmat
E:\ROMS\PROGRAM FILES\MATLAB\BIN\MEX.PL: Error: Link of 'rnt_fillab_mex.mexw32' failed.
??? Error using ==> mex
Unable to complete successfully
So is this error is from link problem(Error: Link of 'rnt_fillab_mex.mexw32' failed)? But why some mex is ok, the others goes wrong?
Who can point out the mistakes I’ve made? I am so sorry if this problem seems very idiotic to you, but at least I have tried very hard to solve it and never give up(I keep looking for answers on web for days but have no result). obviously it’s beyond my ability. So please help me! I am waiting for your precious hints or answers! Thank you!!
Jing
exchange Ph.D student now working in UK
RNT mex_compile problem(solved)
-
- Posts: 2
- Joined: Fri Oct 08, 2010 4:46 pm
- Location: The Maritime Engineering and Water Systems (MEWS)
Re: RNT mex_compile problem(solved)
This problem is sovled. I found it's a very special case because g95 is not supported by matlab by default, and I also use windows (not common).But the solution is to use mingw+g95-MinGW +gnumex.
1.install mingw-get-inst-20101030(like cygwin)
2.install g95-MinGW into .../mingw
3.unzip gnumex,and set gnumex path to matlab
4. in matlab (.../gnumex),run gnumex and set paths
5. in matlab run mex v to see if set is all right
6. in matlab(.../rnt),run mex xxxx.f to get xxxx.mexw32
It is all done!!
The problem I have met before maybe because the version promblem(I am not sure), now I am using MATLAB 7.8 and WINDOWS 7(32 bit).It works well.
1.install mingw-get-inst-20101030(like cygwin)
2.install g95-MinGW into .../mingw
3.unzip gnumex,and set gnumex path to matlab
4. in matlab (.../gnumex),run gnumex and set paths
5. in matlab run mex v to see if set is all right
6. in matlab(.../rnt),run mex xxxx.f to get xxxx.mexw32
It is all done!!
The problem I have met before maybe because the version promblem(I am not sure), now I am using MATLAB 7.8 and WINDOWS 7(32 bit).It works well.