一个朋友给了一段代码让我调试,大意是移植了一些linux下的c程序,需要在windows里面由matlab调用。
粗粗看了一眼相关的东西,主要是用matlab里面的mex函数来调用c函数就可以,编译环境可以实现配置,也可以交互配置。结果一编译,错误就来了
错误是:
>> mex E:\Ctomexw32\ml_texture.c
Select a compiler:
[1] Lcc-win32 C 2.4.1 in D:\PROGRA~1\MATLAB\R2007a\sys\lcc
[2] Microsoft Visual C++ 6.0 in D:\Program Files\Microsoft Visual Studio
[0] None
Compiler: 2
Trying to update options file: C:\Documents and Settings\myching\Application Data\MathWorks\MATLAB\R2007a\mexopts.bat
From template: D:\PROGRA~1\MATLAB\R2007a\bin\win32\mexopts\msvc60opts.bat
Done . . .
ml_texture.c
E:\Ctomexw32\ml_texture.c(48) : warning C4028: formal parameter 4 different from declaration
E:\Ctomexw32\ml_texture.c(51) : error C2065: 'u_int8_t' : undeclared identifier
E:\Ctomexw32\ml_texture.c(51) : error C2065: 'p_img' : undeclared identifier
E:\Ctomexw32\ml_texture.c(51) : warning C4552: '*' : operator has no effect; expected operator with side-effect
E:\Ctomexw32\ml_texture.c(52) : error C2065: 'p_gray' : undeclared identifier
E:\Ctomexw32\ml_texture.c(52) : error C2100: illegal indirection
E:\Ctomexw32\ml_texture.c(52) : warning C4552: '*' : operator has no effect; expected operator with side-effect
E:\Ctomexw32\ml_texture.c(53) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(54) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(55) : error C2275: 'TEXTURE_FEATURE_MAP' : illegal use of this type as an expression
E:\Ctomexw32\CVIPtexture.h(63) : see declaration of 'TEXTURE_FEATURE_MAP'
E:\Ctomexw32\ml_texture.c(55) : error C2065: 'features_used' : undeclared identifier
E:\Ctomexw32\ml_texture.c(56) : error C2275: 'TEXTURE' : illegal use of this type as an expression
E:\Ctomexw32\CVIPtexture.h(43) : see declaration of 'TEXTURE'
E:\Ctomexw32\ml_texture.c(56) : error C2065: 'features' : undeclared identifier
E:\Ctomexw32\ml_texture.c(57) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(58) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(59) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(60) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(61) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(62) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(63) : error C2143: syntax error : missing ';' before 'type'
E:\Ctomexw32\ml_texture.c(64) : error C2065: 'outtest' : undeclared identifier
E:\Ctomexw32\ml_texture.c(64) : warning C4552: '*' : operator has no effect; expected operator with side-effect
E:\Ctomexw32\ml_texture.c(80) : error C2065: 'mrows' : undeclared identifier
E:\Ctomexw32\ml_texture.c(81) : error C2065: 'ncols' : undeclared identifier
E:\Ctomexw32\ml_texture.c(87) : error C2059: syntax error : ')'
E:\Ctomexw32\ml_texture.c(91) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
E:\Ctomexw32\ml_texture.c(95) : error C2223: left of '->ASM' must point to struct/union
E:\Ctomexw32\ml_texture.c(96) : error C2223: left of '->contrast' must point to struct/union
E:\Ctomexw32\ml_texture.c(97) : error C2223: left of '->correlation' must point to struct/union
E:\Ctomexw32\ml_texture.c(98) : error C2223: left of '->variance' must point to struct/union
E:\Ctomexw32\ml_texture.c(99) : error C2223: left of '->IDM' must point to struct/union
E:\Ctomexw32\ml_texture.c(100) : error C2223: left of '->sum_avg' must point to struct/union
E:\Ctomexw32\ml_texture.c(101) : error C2223: left of '->sum_var' must point to struct/union
E:\Ctomexw32\ml_texture.c(102) : error C2223: left of '->sum_entropy' must point to struct/union
E:\Ctomexw32\ml_texture.c(103) : error C2223: left of '->entropy' must point to struct/union
E:\Ctomexw32\ml_texture.c(104) : error C2223: left of '->diff_var' must point to struct/union
E:\Ctomexw32\ml_texture.c(105) : error C2223: left of '->diff_entropy' must point to struct/union
E:\Ctomexw32\ml_texture.c(106) : error C2223: left of '->meas_corr1' must point to struct/union
E:\Ctomexw32\ml_texture.c(107) : error C2223: left of '->meas_corr2' must point to struct/union
E:\Ctomexw32\ml_texture.c(108) : error C2223: left of '->max_corr_coef' must point to struct/union
E:\Ctomexw32\ml_texture.c(110) : error C2065: 'imgsize' : undeclared identifier
E:\Ctomexw32\ml_texture.c(110) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(110) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(111) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(111) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(113) : error C2059: syntax error : ')'
E:\Ctomexw32\ml_texture.c(115) : error C2065: 'i' : undeclared identifier
E:\Ctomexw32\ml_texture.c(116) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(116) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
E:\Ctomexw32\ml_texture.c(116) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(117) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(122) : error C2065: 'imgindex' : undeclared identifier
E:\Ctomexw32\ml_texture.c(122) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(122) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(122) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(122) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(122) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(122) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(123) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(123) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(123) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(123) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(123) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(123) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(124) : error C2065: 'offset' : undeclared identifier
E:\Ctomexw32\ml_texture.c(124) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(124) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(125) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(125) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(125) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(125) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(125) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(125) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(128) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct TEXTURE *'
E:\Ctomexw32\ml_texture.c(144) : error C2065: 'outputsize' : undeclared identifier
E:\Ctomexw32\ml_texture.c(144) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(144) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(145) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(145) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(147) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(147) : warning C4024: 'mxCreateNumericArray_700' : different types for formal and actual parameter 2
E:\Ctomexw32\ml_texture.c(150) : error C2065: 'output' : undeclared identifier
E:\Ctomexw32\ml_texture.c(150) : warning C4047: '=' : 'int ' differs in levels of indirection from 'float *'
E:\Ctomexw32\ml_texture.c(154) : error C2065: 'outputindex' : undeclared identifier
E:\Ctomexw32\ml_texture.c(154) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(154) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(154) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(154) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(155) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(155) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(156) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(156) : error C2106: '=' : left operand must be l-value
E:\Ctomexw32\ml_texture.c(157) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(157) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(158) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(158) : error C2223: left of '->ASM' must point to struct/union
E:\Ctomexw32\ml_texture.c(158) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(160) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(160) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(161) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(161) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(162) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(162) : error C2223: left of '->contrast' must point to struct/union
E:\Ctomexw32\ml_texture.c(162) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(164) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(164) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(165) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(165) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(166) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(166) : error C2223: left of '->correlation' must point to struct/union
E:\Ctomexw32\ml_texture.c(166) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(168) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(168) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(169) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(169) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(170) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(170) : error C2223: left of '->variance' must point to struct/union
E:\Ctomexw32\ml_texture.c(170) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(172) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(172) : error C2105: '++' needs l-value
E:\Ctomexw32\ml_texture.c(173) : warning C4047: 'function' : 'const int *' differs in levels of indirection from 'int '
E:\Ctomexw32\ml_texture.c(173) : warning C4024: 'mxCalcSingleSubscript_700' : different types for formal and actual parameter 3
E:\Ctomexw32\ml_texture.c(174) : error C2109: subscript requires array or pointer type
E:\Ctomexw32\ml_texture.c(174) : fatal error C1003: error count exceeds 100; stopping compilation
D:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Compile of 'E:\Ctomexw32\ml_texture.c' failed.
??? Error using ==> mex at 206
Unable to complete successfully.
分析:看起来,应该首先解决'u_int8_t‘这个类型定义。找了找,windows里面没有,vc里面也没有。网上搜了一下,定义的方式应该是
“typedef unsigned char u_int8_t, u_int8m_t;”
源代码的前面有句话,#include ,所以我就把这个定义放在了types.h里面了。
编译,通过!
但是报告:
>> mex E:\Ctomexw32\ml_texture.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
C:\DOCUME~1\myching\LOCALS~1\Temp\mex_7CC36970-E7CE-4C7B-E1A1-C20DE78ACBCF\ml_texture.obj
Creating library C:\DOCUME~1\myching\LOCALS~1\Temp\mex_7CC36970-E7CE-4C7B-E1A1-C20DE78ACBCF\templib.x and object C:\DOCUME~1\myching\LOCALS~1\Temp\mex_7CC36970-E7CE-4C7B-E1A1-C20DE78ACBCF\templib.exp
ml_texture.obj : error LNK2001: unresolved external symbol _Extract_Texture_Features
ml_texture.mexw32 : fatal error LNK1120: 1 unresolved externals
D:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Link of 'ml_texture.mexw32' failed.
??? Error using ==> mex at 206
Unable to complete successfully.
意思是外部函数连接有问题,看了看那个外部函数Extract_Texture_Features在cvip_pgmtexture.c里面放着呢,于是,想到应该联合编译,
>> mex E:\Ctomexw32\cvip_pgmtexture.c E:\Ctomexw32\ml_texture.c
??? ml_texture requires a single input argument.
??? Error using ==> edit>handleError at 462
Can't edit the MEX-file 'D:\My Documents\MATLAB\cvip_pgmtexture.mexw32'.
这就没有什么问题啦。
阅读(4893) | 评论(0) | 转发(0) |