Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex: Compile error with mxArray
Date: Mon, 17 Aug 2009 12:45:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 66
Message-ID: <h6bjcu$nkc$1@fred.mathworks.com>
References: <h61543$anv$1@fred.mathworks.com> <h619lq$hka$1@fred.mathworks.com> <h61acj$43k$1@fred.mathworks.com> <h61iba$hft$1@fred.mathworks.com> <h630q5$o5b$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250513118 24204 172.30.248.37 (17 Aug 2009 12:45:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Aug 2009 12:45:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1932693
Xref: news.mathworks.com comp.soft-sys.matlab:563937


"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <h630q5$o5b$1@fred.mathworks.com>...
> "James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <h61iba$hft$1@fred.mathworks.com>...
> > "David  Hanau" <hanaud@gmail.com.REMTHIS> wrote in message <h61acj$43k$1@fred.mathworks.com>...
> > > 
> > > This code works and the last releave of MatLab bur not on my V6.1
> > > I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.
> >                :
> > > 	mexEvalString("options.disp=0;");           // for use in calling Matlab function eigs	
> > > 	mexEvalString("options.maxit=500;");		 // for use in calling Matlab function eigs	
> > > 	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs
> > > 	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);
> > > 	input[2]= mxCreateString("la");
> > > 	input[3]= mexGetVariable("caller","options");
> >                     :
> > 
> > I don't have a v6.1 available, but my guess is that one or more of your mx___ or mex___ functions is not available in the older MATLAB version. If it is not available, then there will be no prototype in the mex.h or matrix.h file. So when the compiler gets to the function, absent a prototype, it makes the default assumption that the function returns an int, and of course you are assigning it to a mxArray *. Thus you get the "... invalid assignment int to mxArray * ..." message from the compiler.
> > 
> > My advice is to get a list of all the mx___ and mex___ functions you use and check to see which ones are not available in the earlier version of MATLAB, and then write workarounds for these functions if you can.
> > 
> 
> Looks like the culprit is indeed mexGetVariable. The older MATLAB versions have a different function called mexGetArray. The comparison prototypes are:
> 
> Older versions:
> mxArray *mexGetArray(const char *name, const char *workspace);
> 
> Newer versions:
> mxArray *mexGetVariable(const char *workspace, const char *varname);
> 
> So the name is different, and the argument order has switched. So include this at the top of your source code when compiling using the older version of MATLAB:
> 
> mxArray *mexGetVariable(const char *workspace, const char *varname)
> {
>     return mexGetArray(varname, workspace);
> }
> 
> James Tursa

Thank you for your help. Indeed the mexGetArray do the job perfectly.

No I tacke a new issue, but I think it comes from the memory allocation. 
I am going to look into it and try to debug the mex file!

------------------------------------------------------------------------
       Segmentation violation detected at Mon Aug 17 14:39:10 2009
------------------------------------------------------------------------

Configuration:
  MATLAB Version:   6.1.0.450 (R12.1)
  Operating System: Microsoft Windows 2000
  Window System:    Version 5.1 (Build 2600: Service Pack 2)
  Processor ID:     x86 Family 15 Model 4 Stepping 9, GenuineIntel
  Virtual Machine:  Java 1.1.8 from Sun Microsystems Inc.

Register State:
  EAX = 00000000  EBX = 00074330
  ECX = 00074970  EDX = 00000640
  ESI = 000000c8  EDI = 0000002c
  EBP = 00000160  ESP = 0149a1c8
  EIP = 02210f92  FLG = 00010287

Stack Trace:

This error was detected while a MEX-file was running.  If the MEX-file
is not an official MathWorks function, please examine its source code
for errors.  Please consult the External Interfaces Guide for information
on debugging MEX-files.