Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build mex on linux #34

Merged
merged 3 commits into from Nov 1, 2022
Merged

Conversation

MattiaMontanari
Copy link
Owner

No description provided.

@MattiaMontanari MattiaMontanari linked an issue Oct 18, 2022 that may be closed by this pull request
@Amir-Zargar
Copy link

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

Replace mxCreategkFloatMatrix with mxCreateDoubleMatrix
@MattiaMontanari
Copy link
Owner Author

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

@MattiaMontanari MattiaMontanari merged commit 7a018a3 into master Nov 1, 2022
@MattiaMontanari MattiaMontanari deleted the 33-error-using-mex-matlab-under-linux branch November 28, 2022 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Using mex - Matlab under Linux
2 participants