I tested a simple C++ Mex file which is: #include <iostream.h> #include <fstream.h> void timestwo(double y[], double x[]) { ofstream File; File.open("test.str",ios::out); File << " TEST is OK " << endl; File.close(); y[0] = 2.0*x[0]; } void mexFunction(...) { ...... } The *.dll crashed when I ran it ( although it was compiled successfully ). There is error "Segmentation violation". But the strange thing is that the file "test.str" was created. I wonder if Mex file completely support all C++ class. I replaced above codes with C, which is: #include <stdio.h> void timestwo(double y[], double x[]) { FILE *fp; fp = fopen("test.str","w"); fprintf(fp,"%d\n",x[0]); fclose(fp); y[0] = 2.0*x[0]; } void mexFunction(...) { ...... } I ran and compiled above Mex C file. Everything is fine. andey |