操作系统 win xp sp3
matlab 2010a
matlab编译器 msvc6.0
调用dll的环境 vs2010
在matlab下使用mcc命令生成了动态链接库dll文件,向vc工程中加入了相应的库和目录,把生成dll时同时生成的.h和.cpp文件加入了工程,在没有调用函数的情况下编译,产生了下面错误:
1>c:/documents and settings/zshtang/桌面/videoplatform/pose_estimate.cpp(173): error C2491: 'pose_estimate_tangzesheng' : definition of dllimport function not allowed
出错代码:
LIB_pose_estimate_CPP_API void MW_CALL_CONV pose_estimate_tangzesheng(int nargout, mwArray& T, mwArray& T_stickimgcoor, const mwArray& base_dir, const mwArray& img_dir, const mwArray& img_number, const mwArray& bb) { mclcppMlfFeval(_mcr_inst, "pose_estimate_tangzesheng", nargout, 2, 4, &T, &T_stickimgcoor, &base_dir, &img_dir, &img_number, &bb); }
注:代码是由matlab编译器自动生成,并非本人所写。
如果有人遇到过类似问题,帮忙说下解决办法,谢谢!
查找各种说法尝试无效后,在微软的网站处找到一个解释,参考如下网站:
http://support.microsoft.com/kb/815647/en-us?fr=1
在这个网页里有这样的描述:
You cannot apply the __declspec(dllimport) keyword to implement a function. For example, when you try to define data members (including static data members and functions) as dllimport functions, you receive the following Compiler C2491 error message: