openGJK icon indicating copy to clipboard operation
openGJK copied to clipboard

Build mex on linux

Open MattiaMontanari opened this issue 1 year ago • 2 comments

MattiaMontanari avatar Oct 18 '22 20:10 MattiaMontanari

Thank you Mattia Montanari, I run your code as it is which gives the below error: mex(fullfile('..','..','openGJK.c'),... % Source of openGJK '-largeArrayDims', ... % Support large arrays optflug, ... % Compiler flag for debug/optimisation fullfile('-I','..','..','include'),... % Folder to header files '-outdir', pwd, ... % Ouput directory for writing mex function '-output', 'openGJK',... % Name of ouput mex file '-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files silflag ) Error using mex /home/ctfa/Documents/MATLABCode/Gabriel/OpenGJK_V2/examples/matlab/../../openGJK.c:23:10: fatal error: openGJK/openGJK.h: No such file or directory 23 | #include "openGJK/openGJK.h" | ^~~~~~~~~~~~~~~~~~~ compilation terminated.

I added all folders to path and change the mex command as below and, there is a new error message:

mex('openGJK.c',... % Source of openGJK '-largeArrayDims', ... % Support large arrays optflug, ... % Compiler flag for debug/optimisation '-I/home/ctfa/Documents/MATLABCode/Gabriel/OpenGJK_V2/include',... % Folder to header files '-outdir', pwd, ... % Ouput directory for writing mex function '-output', 'openGJK',... % Name of ouput mex file '-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files silflag ) % Silent/verbose flag /home/ctfa/Documents/MATLABCode/Gabriel/OpenGJK_V2/openGJK.c: In function ‘mexFunction’: /home/ctfa/Documents/MATLABCode/Gabriel/OpenGJK_V2/openGJK.c:733:13: warning: implicit declaration of function ‘mxCreategkFloatMatrix’; did you mean ‘mxCreateStructMatrix’? [-Wimplicit-function-declaration] 733 | plhs[0] = mxCreategkFloatMatrix(1, 1, mxREAL); | ^~~~~~~~~~~~~~~~~~~~~ | mxCreateStructMatrix /home/ctfa/Documents/MATLABCode/Gabriel/OpenGJK_V2/openGJK.c:733:11: warning: assignment to ‘mxArray *’ {aka ‘struct mxArray_tag *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] 733 | plhs[0] = mxCreategkFloatMatrix(1, 1, mxREAL); | ^

Error using mex /usr/bin/ld: /tmp/mex_6162652074770_5763/openGJK.o: in function mexFunction': openGJK.c:(.text+0x47f4): undefined reference to mxCreategkFloatMatrix' collect2: error: ld returned 1 exit status

Amir-Zargar avatar Oct 19 '22 16:10 Amir-Zargar

@Amir-Zargar try now please. I fixed a typo

MattiaMontanari avatar Oct 19 '22 17:10 MattiaMontanari