我試圖編譯.cc文件到mex,並且我在Matlab中使用了mex filename命令。我的編譯器是C:\ PROGRA〜1 \ MATLAB \ R2012b \ sys \ lcc中的[1] Lcc-win32 C 2.4.1。在Matlab中將.cc文件編譯爲mex時出現錯誤
但是,也存在一些誤區:
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
我想第一個錯誤的原因是,有在sys文件夾中沒有time.h中的文件。取而代之的是timeb.h文件。但我不知道以下錯誤的原因。
下面是一些相對代碼:
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); }
誰能給我一個提示?
'sys/time.h'在一個非可移植的Unix/Linux頭文件中,Windows上不可用...可能其餘的錯誤是由該頭文件中未定義的類型引起的。 – Amro
你可以在Windows上使用Cygwin/MinGW GCC編譯器,但這是一個完全不同的故事:) – Amro