nazarovsky / mex-writematrix

Replacement (fast!) for dlmwrite in MATLAB
BSD 3-Clause "New" or "Revised" License
13 stars 5 forks source link

Use in Linux #2

Open HYCLEN opened 8 years ago

HYCLEN commented 8 years ago

Hi,

Thanks for providing this helpful code. It is what I just needed. I just need some more details on how to run it in linux system. I have run it in windows and there was no problem. However, when I tried it in linux, several error messages came out and I think it was probably related to compile issue. Error is like following:

Building with 'gcc'. Error using mex /mex_WriteMatrix.c:6:1: error: expected identifier or ‘(’ before ‘/’ token /mex_WriteMatrix.c:8:1: error: expected identifier or ‘(’ before ‘/’ token /mex_WriteMatrix.c:10:35: warning: character constant too long for its type [enabled by default] /mex_WriteMatrix.c:11:54: warning: character constant too long for its type [enabled by default] /mex_WriteMatrix.c:13:31: warning: multi-character character constant [-Wmultichar] /mex_WriteMatrix.c:13:55: warning: multi-character character constant [-Wmultichar] /mex_WriteMatrix.c: In function ‘mexFunction’: /mex_WriteMatrix.c:110:1: error: expected expression before ‘/’ token /mex_WriteMatrix.c:157:1: error: expected declaration or statement at end of input

It will be greatly helpful for me if let me know how to fix it. Thank you again!

nazarovsky commented 8 years ago

Hi, it seems that your compiler does not understand double slashed style comments http://stackoverflow.com/questions/2223541/why-cant-i-use-style-comments-in-my-c-code

You should either delete comment lines, beginning with // or replace each // "double-slashed" comment with /* */ style comment e.g. replace // if (!mxIsChar(prhs[3]) || mxGetN(prhs[3])>1) { with /* if (!mxIsChar(prhs[3]) || mxGetN(prhs[3])>1) { */

Hope this helps

HYCLEN commented 8 years ago

Thank you for your comment. I have made correction and compile works well now. However, when I try to implement the function matlab is suddenly crashed with error messages.

double free or corruption (out): 0x00007fefb559e0d0 ***

nazarovsky commented 8 years ago

Hmm, seems that there is some problem with memory allocation/freeing. You could try this solution http://stackoverflow.com/questions/24085098/mxcalloc-and-mxfree-with-openmp-results-double-free-or-corruption

tkoch96 commented 5 years ago

I'd be very interested in a solution. Works great on my windows machine but not on linux.

Tried replacing some mx functions with their C counterparts such as calloc and free. Still getting the double free error. I'm not very good with C so I wouldn't know how to change all of the functions with 'mx' in them.

gongshuai0606 commented 1 year ago

Hi, how did you use it in linux?when I mex the .c in the command window of matlab,several error came out , and I'm not good with C.