From: Kimonas Fountoulakis on
Hi

I have a c program that makes some engine calls, I compile it by typing:

mex -v -g -c exampleMtxFree.c

and
mex -g mtxFreeIPM.o exampleMtxFree.o -o hopdmcs -L ../../interface -linterface -L ../../hopdm -lhopdm -lm /usr/lib/libg2c.so.0 -lm ~/Desktop/matlab/bin/glnx86/libeng.so

The above commands create the file hopdmcs.mexglx

If I try to run the program from a terminal or through MATLAB command line by typing

../hopdmcs.mexglx

I get a segmentation fault! The program doesn't even start, I tried to run it into a debugger to see what is going wrong, but even if a put a breakpoint on main function, it still gives me a segmentation fault.

Any ideas pls?

Thanks in advance!
From: Kimonas Fountoulakis on
"Kimonas Fountoulakis" <kfoynt(a)hotmail.com> wrote in message <i1sv4f$lak$1(a)fred.mathworks.com>...
> Hi
>
> I have a c program that makes some engine calls, I compile it by typing:
>
> mex -v -g -c exampleMtxFree.c
>
> and
> mex -g mtxFreeIPM.o exampleMtxFree.o -o hopdmcs -L ../../interface -linterface -L ../../hopdm -lhopdm -lm /usr/lib/libg2c.so.0 -lm ~/Desktop/matlab/bin/glnx86/libeng.so
>
> The above commands create the file hopdmcs.mexglx
>
> If I try to run the program from a terminal or through MATLAB command line by typing
>
> ./hopdmcs.mexglx
>
> I get a segmentation fault! The program doesn't even start, I tried to run it into a debugger to see what is going wrong, but even if a put a breakpoint on main function, it still gives me a segmentation fault.
>
> Any ideas pls?
>
> Thanks in advance!




--------------------------------------------------------


I also have to say that I tried to compile it through the terminal and I get:



In file included from ../../../matlab/extern/include/engine.h:45,
from exampleMtxFree.c:27:
.../../../matlab/extern/include/matrix.h:303:22: error: tmwtypes.h: No such file or directory
In file included from ../../../matlab/extern/include/engine.h:45,
from exampleMtxFree.c:27:
.../../../matlab/extern/include/matrix.h:318: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxLogical&#8217;
.../../../matlab/extern/include/matrix.h:330: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;char16_t&#8217;
.../../../matlab/extern/include/matrix.h:337: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxChar&#8217;
In file included from ../../../matlab/extern/include/engine.h:45,
from exampleMtxFree.c:27:
.../../../matlab/extern/include/matrix.h:504: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsNumeric&#8217;
.../../../matlab/extern/include/matrix.h:510: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsCell&#8217;
.../../../matlab/extern/include/matrix.h:516: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsLogical&#8217;
.../../../matlab/extern/include/matrix.h:522: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsChar&#8217;
.../../../matlab/extern/include/matrix.h:528: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsStruct&#8217;
.../../../matlab/extern/include/matrix.h:534: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsOpaque&#8217;
.../../../matlab/extern/include/matrix.h:540: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsFunctionHandle&#8217;
.../../../matlab/extern/include/matrix.h:548: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsObject&#8217;
.../../../matlab/extern/include/matrix.h:578: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsComplex&#8217;
.../../../matlab/extern/include/matrix.h:584: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsSparse&#8217;
.../../../matlab/extern/include/matrix.h:591: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsDouble&#8217;
.../../../matlab/extern/include/matrix.h:598: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsSingle&#8217;
.../../../matlab/extern/include/matrix.h:605: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsInt8&#8217;
.../../../matlab/extern/include/matrix.h:612: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsUint8&#8217;
.../../../matlab/extern/include/matrix.h:619: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsInt16&#8217;
.../../../matlab/extern/include/matrix.h:626: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsUint16&#8217;
.../../../matlab/extern/include/matrix.h:633: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsInt32&#8217;
.../../../matlab/extern/include/matrix.h:640: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsUint32&#8217;
.../../../matlab/extern/include/matrix.h:647: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsInt64&#8217;
.../../../matlab/extern/include/matrix.h:654: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsUint64&#8217;
.../../../matlab/extern/include/matrix.h:660: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxGetNumberOfDimensions&#8217;
.../../../matlab/extern/include/matrix.h:672: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:730: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:779: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsFromGlobalWS&#8217;
.../../../matlab/extern/include/matrix.h:785: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;bool&#8217;
.../../../matlab/extern/include/matrix.h:797: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:809: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsEmpty&#8217;
.../../../matlab/extern/include/matrix.h:817: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:823: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:829: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:835: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:841: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxGetNzmax&#8217;
.../../../matlab/extern/include/matrix.h:847: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:860: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxCalcSingleSubscript&#8217;
.../../../matlab/extern/include/matrix.h:874: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:880: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:899: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:905: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:913: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:920: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:930: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:938: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwIndex&#8217;
.../../../matlab/extern/include/matrix.h:950: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsClass&#8217;
.../../../matlab/extern/include/matrix.h:962: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:971: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:978: error: expected &#8216;;&#8217;, &#8216;,&#8217; or &#8216;)&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:993: error: expected &#8216;)&#8217; before &#8216;ndim&#8217;
.../../../matlab/extern/include/matrix.h:1000: error: expected &#8216;)&#8217; before &#8216;ndim&#8217;
.../../../matlab/extern/include/matrix.h:1007: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1013: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;*&#8217; token
.../../../matlab/extern/include/matrix.h:1019: error: expected &#8216;)&#8217; before &#8216;ndim&#8217;
.../../../matlab/extern/include/matrix.h:1029: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1038: error: expected &#8216;)&#8217; before &#8216;value&#8217;
.../../../matlab/extern/include/matrix.h:1044: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsLogicalScalar&#8217;
.../../../matlab/extern/include/matrix.h:1050: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsLogicalScalarTrue&#8217;
.../../../matlab/extern/include/matrix.h:1066: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1072: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1080: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:1091: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:1107: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;mwSize&#8217;
.../../../matlab/extern/include/matrix.h:1120: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1127: error: expected &#8216;)&#8217; before &#8216;m&#8217;
.../../../matlab/extern/include/matrix.h:1134: error: expected &#8216;)&#8217; before &#8216;ndim&#8217;
.../../../matlab/extern/include/matrix.h:1148: error: expected &#8216;)&#8217; before &#8216;ndim&#8217;
.../../../matlab/extern/include/matrix.h:1212: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsFinite&#8217;
.../../../matlab/extern/include/matrix.h:1220: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsInf&#8217;
.../../../matlab/extern/include/matrix.h:1228: error: expected &#8216;=&#8217;, &#8216;,&#8217;, &#8216;;&#8217;, &#8216;asm&#8217; or &#8216;__attribute__&#8217; before &#8216;mxIsNaN&#8217;
In file included from exampleMtxFree.c:27:
.../../../matlab/extern/include/engine.h:76: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;bool&#8217;
.../../../matlab/extern/include/engine.h:85: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;bool&#8217;


I checked some errors like: the error: tmwtypes.h: and the file indeed exists into the directory!!
From: Kimonas Fountoulakis on
An update!!!

the commands that I used in matlab are:

mex -g -c -f /home/kfoynt/Desktop/matlab/bin/engopts.sh exampleMtxFree.c

and

mex -v -g -f /home/kfoynt/Desktop/matlab/bin/engopts.sh mtxFreeIPM.o exampleMtxFree.o -o hopdmcs -L ../../interface -linterface -L ../../hopdm -lhopdm -lm /usr/lib/libg2c.so.0 -lm ~/Desktop/matlab/bin/glnx86/libeng.so

it compiles successfully

but when I type to the bash terminal:

../hopdmcs

I get:

../hopdmcs: error while loading shared libraries: libeng.so: cannot open shared object file: No such file or directory


any ideas again??
From: Kimonas Fountoulakis on
Ok, I was able to make it work... but now I am getting:

Can't start matlab engine!!

Please help! :-)