Skip Menu |

This queue is for tickets about the Math-Matlab-Engine CPAN distribution.

Report information
The Basics
Id: 12039
Status: open
Priority: 0/
Queue: Math-Matlab-Engine

People
Owner: Nobody in particular
Requestors: amit.goel [...] intel.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Can't Compile with Matlab version 7.0.0.19901 (R14) on Linux
Perl version: 5.8.5 on Linux /usr/intel/pkgs/gcc/3.3/bin/gcc -c -I/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include -fno-strict-aliasing -pipe -I/usr/intel/00r1/include -I/usr/intel/pkgs/libxml2/2.6.11/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O3 -DVERSION=\"0.02\" -DXS_VERSION=\"0.02\" -fpic "-I/usr/intel/pkgs/perl/5.8.5/lib/5.8.5/i686-linux-64int/CORE" Engine.c In file included from /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/matrix.h:200, from /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/engine.h:43, from Engine.xs:5: /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/tmwtypes.h:680: warning: useless keyword or type name in empty declaration /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/tmwtypes.h:680: warning: empty declaration Engine.c: In function `XS_Math__Matlab__Engine_Close': Engine.c:93: warning: cast to pointer from integer of different size Engine.c: In function `XS_Math__Matlab__Engine_EvalString': Engine.c:118: warning: cast to pointer from integer of different size Engine.c: In function `XS_Math__Matlab__Engine_GetArrayList': Engine.c:143: warning: cast to pointer from integer of different size Engine.xs:89:38: macro "engGetArray" passed 2 arguments, but takes just 0 Engine.xs:89: error: `engGetArray' undeclared (first use in this function) Engine.xs:89: error: (Each undeclared identifier is reported only once Engine.xs:89: error: for each function it appears in.) Engine.xs:96: warning: assignment discards qualifiers from pointer target type Engine.c: In function `XS_Math__Matlab__Engine_GetArrayListRef': Engine.c:191: warning: cast to pointer from integer of different size Engine.xs:124:38: macro "engGetArray" passed 2 arguments, but takes just 0 Engine.xs:124: error: `engGetArray' undeclared (first use in this function) .. Engine.xs:419: error: `engGetArray' undeclared (first use in this function) Engine.xs:428: warning: assignment discards qualifiers from pointer target type make: *** [Engine.o] Error 1
From: Hafen McCormick
On Mon Mar 28 14:39:03 2005, guest wrote: Show quoted text
> Perl version: 5.8.5 on Linux > > /usr/intel/pkgs/gcc/3.3/bin/gcc -c > -I/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include > -fno-strict-aliasing -pipe -I/usr/intel/00r1/include > -I/usr/intel/pkgs/libxml2/2.6.11/include -D_LARGEFILE_SOURCE > -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O3 -DVERSION=\"0.02\" > -DXS_VERSION=\"0.02\" -fpic "- > I/usr/intel/pkgs/perl/5.8.5/lib/5.8.5/i686-linux-64int/CORE" > Engine.c > In file included from >
/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/matrix.h:200, Show quoted text
> from >
/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/engine.h:43, Show quoted text
> from Engine.xs:5: >
/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/tmwtypes.h:680: Show quoted text
> warning: useless keyword or type name in empty declaration >
/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include/tmwtypes.h:680: Show quoted text
> warning: empty declaration > Engine.c: In function `XS_Math__Matlab__Engine_Close': > Engine.c:93: warning: cast to pointer from integer of different size > Engine.c: In function `XS_Math__Matlab__Engine_EvalString': > Engine.c:118: warning: cast to pointer from integer of different size > Engine.c: In function `XS_Math__Matlab__Engine_GetArrayList': > Engine.c:143: warning: cast to pointer from integer of different size > Engine.xs:89:38: macro "engGetArray" passed 2 arguments, but takes > just 0 > Engine.xs:89: error: `engGetArray' undeclared (first use in this > function) > Engine.xs:89: error: (Each undeclared identifier is reported only once > Engine.xs:89: error: for each function it appears in.) > Engine.xs:96: warning: assignment discards qualifiers from pointer > target type > Engine.c: In function `XS_Math__Matlab__Engine_GetArrayListRef': > Engine.c:191: warning: cast to pointer from integer of different size > Engine.xs:124:38: macro "engGetArray" passed 2 arguments, but takes > just 0 > Engine.xs:124: error: `engGetArray' undeclared (first use in this > function) > .. > Engine.xs:419: error: `engGetArray' undeclared (first use in this > function) > Engine.xs:428: warning: assignment discards qualifiers from pointer > target type > make: *** [Engine.o] Error 1
I had the same difficulty. The simple fix is to edit Engine.xs and add the line #define V5_COMPAT so that it exists before this line #include "engine.h" Good luck.
On Mon Mar 28 14:39:03 2005, guest wrote: Show quoted text
> Perl version: 5.8.5 on Linux > > /usr/intel/pkgs/gcc/3.3/bin/gcc -c > -
I/nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include Show quoted text
> -fno-strict-aliasing -pipe -I/usr/intel/00r1/include > -I/usr/intel/pkgs/libxml2/2.6.11/include -D_LARGEFILE_SOURCE > -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O3 -DVERSION=\"0.02
\" Show quoted text
> -DXS_VERSION=\"0.02\" -fpic "- > I/usr/intel/pkgs/perl/5.8.5/lib/5.8.5/i686-linux-64int/CORE" > Engine.c > In file included from > /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/incl
ude/matrix.h:200, Show quoted text
> from > /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/incl
ude/engine.h:43, Show quoted text
> from Engine.xs:5: > /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include
/tmwtypes.h:680: Show quoted text
> warning: useless keyword or type name in empty declaration > /nfs/site/eda/data/disk0001/mathworks/matlab/14/common/extern/include
/tmwtypes.h:680: Show quoted text
> warning: empty declaration > Engine.c: In function `XS_Math__Matlab__Engine_Close': > Engine.c:93: warning: cast to pointer from integer of different size > Engine.c: In function `XS_Math__Matlab__Engine_EvalString': > Engine.c:118: warning: cast to pointer from integer of different size > Engine.c: In function `XS_Math__Matlab__Engine_GetArrayList': > Engine.c:143: warning: cast to pointer from integer of different size > Engine.xs:89:38: macro "engGetArray" passed 2 arguments, but takes > just 0 > Engine.xs:89: error: `engGetArray' undeclared (first use in this > function) > Engine.xs:89: error: (Each undeclared identifier is reported only
once Show quoted text
> Engine.xs:89: error: for each function it appears in.) > Engine.xs:96: warning: assignment discards qualifiers from pointer > target type > Engine.c: In function `XS_Math__Matlab__Engine_GetArrayListRef': > Engine.c:191: warning: cast to pointer from integer of different size > Engine.xs:124:38: macro "engGetArray" passed 2 arguments, but takes > just 0 > Engine.xs:124: error: `engGetArray' undeclared (first use in this > function) > .. > Engine.xs:419: error: `engGetArray' undeclared (first use in this > function) > Engine.xs:428: warning: assignment discards qualifiers from pointer > target type > make: *** [Engine.o] Error 1
From: cpan_reply [...] yesbutno.com
On Fri Feb 17 05:52:31 2006, guest wrote: Show quoted text
> On Mon Mar 28 14:39:03 2005, guest wrote:
> > Perl version: 5.8.5 on Linux
[snip] Show quoted text
> > Engine.xs:124:38: macro "engGetArray" passed 2 arguments, but takes > > just 0
[snip] Show quoted text
> > make: *** [Engine.o] Error 1
> > > I had the same difficulty. The simple fix is to edit Engine.xs > and add the line > > #define V5_COMPAT > > so that it exists before this line > > #include "engine.h"
I had a similar problem. It seems lile the module is using methods in the matlab engine that are deprecated. I've included a patch which fixes this, and also updates the StringEval method. Text output from MATLAB commands, are now returned from EvalString instead of 1 or 0, and undef is returned in case of error. Hope that helps, Pete
--- Math-Matlab-Engine-0.02/Engine.xs 2003-11-26 22:16:08.000000000 +0100 +++ Math-Matlab-Engine/Engine.xs 2006-11-15 19:21:49.000000000 +0100 @@ -3,7 +3,7 @@ #include "XSUB.h" #include "engine.h" -#define BUFSIZE 256 +#define BUFSIZE 1024*256 static int not_here(char *s) @@ -19,8 +19,13 @@ return 0; } -MODULE = Math::Matlab::Engine PACKAGE = Math::Matlab::Engine PREFIX = eng +typedef struct { + Engine * ep; + char * EvalBuf; +} EngineIface; +MODULE = Math::Matlab::Engine PACKAGE = Math::Matlab::Engine PREFIX = eng +PROTOTYPES: ENABLE double constant(sv,arg) @@ -37,81 +42,112 @@ -Engine * +EngineIface * new(CLASS) char * CLASS CODE: { - Engine *ep; + EngineIface *eng; - if (!(ep = engOpen("\0"))) { - croak ("Can't start MATLAB engine"); - } + if (NULL == (eng = malloc(sizeof(EngineIface)))) + croak ("Cannot allocate engine object"); + + if (!(eng->ep = engOpen("") )) + croak ("Failed to start MATLAB engine"); + + // Alloc the buffer for the output of evals + if (NULL == (eng->EvalBuf = malloc(BUFSIZE))) + croak ("Failed to allocate eval output buffer"); + + engOutputBuffer(eng->ep, eng->EvalBuf, BUFSIZE); + - RETVAL = ep; + RETVAL = eng; } OUTPUT: RETVAL + + int -engClose(ep) - Engine * ep +engClose(eng) + EngineIface * eng CODE: { - RETVAL = 1 - engClose(ep); + RETVAL = 1 - engClose(eng->ep); } OUTPUT: RETVAL -int -engEvalString(ep, string) - Engine * ep +void +engDESTROY(eng) + EngineIface * eng + CODE: + { + engClose(eng->ep); + free(eng->EvalBuf); + free(eng); + } + +SV* +engEvalString(eng, string) + EngineIface * eng const char * string CODE: { - RETVAL = (engEvalString(ep, string) == 0); + if (engEvalString(eng->ep, string) == 0) { +# fprintf(stderr, "DEBUG: String frmo eval=%s$\n",eng->EvalBuf); +# fprintf(stderr, "DEBUG: EvalString on MATLAB engine %x\n",eng->ep); + RETVAL = newSVpv(eng->EvalBuf,0); + } else { + // We couldnt talk to the matlab engine. + // return undef +# fprintf(stderr, "ERROR: Could not talk to MATLAB engine: %x\n",eng->ep); + XSRETURN_UNDEF; + } } OUTPUT: RETVAL AV * -engGetArrayList(ep, name) - Engine * ep +engGetArrayList(eng, name) + EngineIface * eng const char * name PPCODE: { mxArray *matrix; - int nrdim, *dims, i, nelem; + int *dims, i, nelem; + int nrdim; double *vals; - matrix = engGetArray(ep, name); + matrix = engGetVariable(eng->ep, name); if (matrix == NULL) XSRETURN_UNDEF; - nrdim = mxGetNumberOfDimensions(matrix); - printf("%d dimensions\n",nrdim); + nrdim = (int) mxGetNumberOfDimensions(matrix); +// printf("%d dimensions\n",nrdim); - dims = mxGetDimensions(matrix); + dims = (int*) mxGetDimensions(matrix); nelem = 1; for(i=0;i<nrdim;i++) { - printf("\t%d\n",*(dims+i)); +// printf("\t%d\n",*(dims+i)); nelem *= *(dims+i); } vals = mxGetPr(matrix); for(i=0;i<nelem;i++) { XPUSHs(sv_2mortal(newSVnv(*(vals+i)))); - printf("%6.4f,",*(vals+i)); +// printf("%6.4f,",*(vals+i)); } - printf("\n"); +// printf("\n"); } SV * -engGetArrayListRef(ep, name) - Engine * ep +engGetArrayListRef(eng, name) + EngineIface * eng const char * name CODE: @@ -121,26 +157,26 @@ double *vals; AV *arr; - matrix = engGetArray(ep, name); + matrix = engGetVariable(eng->ep, name); if (matrix == NULL) XSRETURN_UNDEF; nrdim = mxGetNumberOfDimensions(matrix); - printf("%d dimensions\n",nrdim); +# printf("%d dimensions\n",nrdim); - dims = mxGetDimensions(matrix); + dims = (int*) mxGetDimensions(matrix); nelem = 1; for(i=0;i<nrdim;i++) { - printf("\t%d\n",*(dims+i)); +# printf("\t%d\n",*(dims+i)); nelem *= *(dims+i); } vals = mxGetPr(matrix); arr = newAV(); for(i=0;i<nelem;i++) { av_push(arr, newSVnv(*(vals+i))); - printf("%6.4f,",*(vals+i)); +# printf("%6.4f,",*(vals+i)); } - printf("\n"); +# printf("\n"); RETVAL = newRV_inc((SV *) arr); } @@ -148,8 +184,8 @@ RETVAL SV * -engGetArray2dim(ep, name) - Engine * ep +engGetArray2dim(eng, name) + EngineIface * eng const char * name CODE: @@ -159,20 +195,20 @@ double *vals; AV *arr, *mat; - matrix = engGetArray(ep, name); + matrix = engGetVariable(eng->ep, name); if (matrix == NULL) XSRETURN_UNDEF; nrdim = mxGetNumberOfDimensions(matrix); - printf("%d dimensions\n",nrdim); +# printf("%d dimensions\n",nrdim); if (nrdim != 2) XSRETURN_UNDEF; - dims = mxGetDimensions(matrix); + dims = (int*) mxGetDimensions(matrix); nelem = 1; for(i=0;i<nrdim;i++) { - printf("\t%d\n",*(dims+i)); +# printf("\t%d\n",*(dims+i)); nelem *= *(dims+i); } vals = mxGetPr(matrix); @@ -180,12 +216,12 @@ for(i=0;i<*(dims+1);i++) { arr = newAV(); for(j=0;j<*dims;j++) { - printf("%6.4f,",*vals); +# printf("%6.4f,",*vals); av_push(arr, newSVnv(*(vals++))); } av_push(mat, newRV_inc((SV *) arr)); } - printf("\n"); +# printf("\n"); RETVAL = newRV_inc((SV *) mat); } @@ -193,8 +229,8 @@ RETVAL SV * -engGetArray(ep, name) - Engine * ep +engGetArray(eng, name) + EngineIface * eng const char * name CODE: @@ -204,14 +240,14 @@ double *data; AV **arrays; - matrix = engGetArray(ep, name); + matrix = engGetVariable(eng->ep, name); if (matrix == NULL) XSRETURN_UNDEF; dim = mxGetNumberOfDimensions(matrix); # 30.10.02: reverse order of d - dtmp = mxGetDimensions(matrix); + dtmp = (int*) mxGetDimensions(matrix); d = (int *) calloc(dim + 1, sizeof(int)); for(i=0;i<dim;i++) *(d+dim-1-i) = *(dtmp+i); @@ -256,8 +292,8 @@ RETVAL int -engPutArray(ep, name, dims, data) - Engine * ep +engPutArray(eng, name, dims, data) + EngineIface * eng const char * name SV * dims SV * data @@ -277,8 +313,9 @@ # printf("found %d dimensions\n", ndim + 1); d = (int *) calloc(ndim + 1, sizeof(int)); # 30.10.02: reverse order of creation of d -# for(i=0;i<=ndim;i++) { - for(i=ndim;i>=0;i--) { +# 08.11.06: Reset this back to original order. Now is consistent wtih PutMatrix + for(i=0;i<=ndim;i++) { +# for(i=ndim;i>=0;i--) { sv = av_shift(dimarr); if (SvIOK(sv)) { # printf("Integer value: %d\n", SvIV(sv)); @@ -294,7 +331,7 @@ # printf("Don't know what it is!\n"); *(d+i) = 1; } -# d[i] = (int) SvIV(sv); + d[i] = (int) SvIV(sv); # printf("dimension %d: %d\n", i, d[i]); } @@ -303,7 +340,8 @@ # printf("Array has %d elements\n", nelem); - mat = mxCreateDoubleMatrix(1, nelem + 1, mxREAL); + mat = mxCreateNumericArray( ndim+1, (size_t*) d, mxDOUBLE_CLASS, mxREAL); + #mat = mxCreateDoubleMatrix(1, nelem + 1, mxREAL); values = mxGetPr(mat); # printf("array has %d elements\n", nelem + 1); @@ -329,17 +367,22 @@ # printf("value nr. %d is %f\n", i + 1, *(values+i)); } - mxSetName(mat, name); - mxSetDimensions(mat, d, ndim + 1); + // This is now obsolete. Not needed. + //mxSetName(mat, name); - RETVAL = 1 - engPutArray(ep, mat); + // We now set the dims when we create the array + //mxSetDimensions(mat, (mwSize*) d, ndim + 1); + + + RETVAL = 1 - engPutVariable(eng->ep, name, mat); +# RETVAL = 1; } OUTPUT: RETVAL int -engPutMatrix(ep, name, rows, cols, data) - Engine * ep +engPutMatrix(eng, name, rows, cols, data) + EngineIface * eng const char * name SV * rows SV * cols @@ -396,17 +439,17 @@ if (j > nelem) j-=nelem; } + // Obsolete. Now not needed + // mxSetName(mat, name); - mxSetName(mat, name); - - RETVAL = 1 - engPutArray(ep, mat); + RETVAL = 1 - engPutVariable(eng->ep, name, mat); } OUTPUT: RETVAL SV * -engGetMatrix(ep, name) - Engine * ep +engGetMatrix(eng, name) + EngineIface * eng const char * name CODE: @@ -416,7 +459,7 @@ double *vals; AV *arr, *mat; - matrix = engGetArray(ep, name); + matrix = engGetVariable(eng->ep, name); if (matrix == NULL) XSRETURN_UNDEF; @@ -426,7 +469,7 @@ if (nrdim != 2) XSRETURN_UNDEF; - dims = mxGetDimensions(matrix); + dims = (int*) mxGetDimensions(matrix); nelem = 1; for(i=0;i<nrdim;i++) { # printf("\t%d\n",*(dims+i)); --- Math-Matlab-Engine-0.02/typemap 2003-11-26 22:16:08.000000000 +0100 +++ Math-Matlab-Engine/typemap 2006-11-15 18:31:15.000000000 +0100 @@ -1,13 +1,13 @@ TYPEMAP -Engine * ENG_OBJ +EngineIface * ENG_OBJ const char * T_PV double * T_PV INPUT ENG_OBJ - { $var = ($type) SvIV((SV*)SvRV($arg)); - } +ENG_REF + $var = ($type) SvIV((SV*)SvRV($arg)); OUTPUT ENG_OBJ --- Math-Matlab-Engine-0.02/t/matrix.t 2003-11-26 22:16:08.000000000 +0100 +++ Math-Matlab-Engine/t/matrix.t 2006-11-15 18:36:49.000000000 +0100 @@ -6,11 +6,15 @@ ok(1); $ep = Math::Matlab::Engine->new; -ok($ep->PutArray('N',[3,2],[1,2,3,4,5,6])); +ok($ep->PutArray('N',[2,3],[1,4,2,5,3,6])); -ok($ep->PutArray('E1',[1,3],[1,0,0])); -ok($ep->PutArray('E2',[1,3],[0,1,0])); -ok($ep->PutArray('E3',[1,3],[0,0,1])); +ok($ep->PutArray('E1',[3,1],[1,0,0])); +ok($ep->PutArray('E2',[3,1],[0,1,0])); +ok($ep->PutArray('E3',[3,1],[0,0,1])); + +#$ep->PutMatrix('Ntest',2,3,[1,2,3,4,5,6]); +#$ep->EvalString("desktop"); +#sleep 30; ok($ep->EvalString("N1=N*E1")); ok($ep->EvalString("N2=N*E2")); @@ -20,3 +24,5 @@ ok($n1->[0]->[0],1); ok(!defined($n1->[0]->[1])); ok($n1->[1]->[0],4); + +$ep->Close;