常见的VC和matlab混合开发遇到的问题

手册/FAQ (513) 2016-04-21 09:39:04

常见的VC和matlab混合开发遇到的问题

1. error C2011: '_INTERFACE_INFO' : 'struct' type redefinition的问题。

        对于VC 6.0工程,在StdAfx.h里的所有包含头文件之前添加下面两句代码:

  • #define WINVER 0x0501  
  • #define _WIN32_WINNT 0x0501  

 

对于VC 6.0以上的工程,则需要修改targetver.h,把其中的 0X0600 修改为 0X0501,即:

#define WINVER 0x0600 ===>> #define WINVER 0x0501

 

#define _WIN32_WINNT 0x0600 ===>> #define _WIN32_WINNT 0x0501

 

2.运行时出现__security_init_cookie的错误。

     在集成mcc编译生成的库后运行出错,错误代码处为:

  • #if defined (_WIN64)  
  •     cookie = systime.ft_scalar;  
  • #else  /* defined (_WIN64) */  
  •     cookie = systime.ft_struct.dwLowDateTime; // 出错处  
  •     cookie ^= systime.ft_struct.dwHighDateTime;  
  • #endif  /* defined (_WIN64) */  

 

         请重新运行mex -setup 和mbuild -setup两个命令对编译器进行配置。

 

3.在使用mcc工具对m文件进行编译时出现错误:

The file  

  'E:\MyApp\src\CombineDev\Matlab\mccdemo1.dll'  

appears to be a MEX-file. It shadows the M-file  

 'E:\MyApp\src\CombineDev\Matlab\mccdemo1.m'  

but will not execute properly at runtime, as it does not export a function named 'mexFunction.' 

??? Error using ==> mcc

Error executing mcc, return status = 1 (0x1).

 

          请确保存放你的m文件下没有对应的dll文件。比如你要编译E:\MyApp\src\CombineDev\Matlab\mccdemo1.m,请保证E:\MyApp\src\CombineDev\Matlab目录下对应生成的dll文件mccdemo1.dll,如果有,请把它删除掉。

THE END