0

I am trying to complie a .cc file to mex, and I am using mex filename command in Matlab. My complier is [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012b\sys\lcc .

However, there are some errors:

 lcc preprocessor error: learn.cc:5 Could not find include file <sys/time.h> 
Error learn.cc: 70  illegal statement termination 
Error learn.cc: 70  skipping `int' 
Error learn.cc: 70  undeclared identifier `alen' 
Error learn.cc: 71  illegal statement termination 
Error learn.cc: 71  skipping `int' 
Error learn.cc: 71  undeclared identifier `blen' 
Error learn.cc: 87  invalid struct field declarations 
Error learn.cc: 87  syntax error; found `collapsed' expecting `}' 
Error learn.cc: 87  skipping `collapsed' `*' `x' 
Error learn.cc: 93  unrecognized declaration 
Warning learn.cc: 93  empty declaration 
Error learn.cc: 97  undefined size for `incomplete struct timeval defined at learn.cc 97 tp' 
Error learn.cc: 99  unknown field `tv_usec' of `incomplete struct timeval defined at learn.cc 97' 
Error learn.cc: 102  syntax error; found `double' expecting `;' 
Error learn.cc: 103  syntax error; found `double' expecting `;' 
Error learn.cc: 106  missing parameter type 
Error learn.cc: 106  syntax error; found `X' expecting `)' 
Error learn.cc: 106  skipping `X' `,' 
Error learn.cc: 106  syntax error; found `double' expecting `{' 
Error learn.cc: 106  missing identifier 
Error learn.cc: 106  too many errors 

I guess the reason for the first error is that there is no time.h file in the sys folder. Instead there is timeb.h file. But I don't know the reason to the following errors.

Here are some relative codes:

line 70     int alen = **((int **)a);
line 71     int blen = **((int **)b);
line 86-93  struct data {
  collapsed *x;
  int num;
  int numblocks;
  int *blocksizes;
  float *regmult;
  float *learnmult;
};
line 96-100 void seed_time() {
 struct timeval tp;
 check(gettimeofday(&tp, NULL) == 0);
 srand48((long)tp.tv_usec);
}
line 102 static inline double min(double x, double y) { return (x <= y ? x : y); }
line 103 static inline double max(double x, double y) { return (x <= y ? y : x); }

Can anyone give me a hint?

Brendon Tsai
  • 1,267
  • 1
  • 17
  • 31
  • `sys/time.h` in a non-portable Unix/Linux header file, not available on Windows... Probably the rest of the errors are caused by undefined types from that header file. – Amro Jan 13 '14 at 16:15
  • you could look into using Cygwin/MinGW GCC compilers on Windows, but that's a completely different story :) – Amro Jan 13 '14 at 16:22

1 Answers1

0

As far as i can tell, there is nothing wrong with lines 70,71. Are a,b integer double arrays declared and allocated with something like:

int ** a = malloc(4 * sizeof(int*) ); for (int var = 0; var < 4; ++var) { a[var] = malloc(3*sizeof(int)); } ?

Are you sure that the sys/time.h file can be replaced by sys/timeb.h file? Have you tried? sys/time.h looks like a pretty linux/unix specific file. Are you sure that the sys/ folder refers to your matlab sys directory (C:\PROGRA~1\MATLAB\R2012b\sys\lcc)?

In general, it looks like you are trying to compile a linux .mex file on a windows machine. For example gettimeofday is a linux pure call (according to this answer): Equivalent of gettimeday() for Windows

Community
  • 1
  • 1
alexandre iolov
  • 582
  • 3
  • 11