MATLAB R2012a与vs2010混合编程 error LNK2019

时间:2021-08-03 21:28:08

转载自链接:http://www.xuebuyuan.com/2069358.html

MATLAB R2012a与vs2010混合编程 error LNK2019

当按照如下连接:

http://blog.sina.com.cn/s/blog_a5fdbf0101018n91.html

配置好后,出现连接错误:

Error 1 errorLNK2019: unresolved external symbol "__declspec(dllimport) void __cdecladd(int,class mwArray &,class mwArray const &,class mwArray const&)" (__imp_?add@@YAXHAAVmwArray@@ABV1@1@Z)
referenced in function _main 

Error 2 errorLNK2019: unresolved external symbol _addInitialize referenced in function_main 

Error 3 errorLNK2019: unresolved external symbol _mclGetMatrix_proxy referenced in function"public: __thiscall mwArray::mwArray(unsigned int,unsigned int,enummxClassID,enum mxComplexity)" (??0mwArray@@QAE@IIW4mxClassID@@W4mxComplexity@@@Z

Error 4 errorLNK2019: unresolved external symbol _mclcppGetLastError_proxy referenced infunction "public: static void __cdecl mwException::raise_error(void)"(?raise_error@mwException@@SAXXZ

Error 5 errorLNK2019: unresolved external symbol _mclcppCreateError_proxy referenced infunction "public: __thiscall mwException::mwException(void)" (??0mwException@@QAE@XZ

Error 6 errorLNK2019: unresolved external symbol _ref_count_obj_addref_proxy referenced infunction "public: __thiscall mwException::mwException(class mwExceptionconst &)" (??0mwException@@QAE@ABV0@@Z

Error 7 errorLNK2019: unresolved external symbol _ref_count_obj_release_proxy referenced infunction "public: virtual __thiscall mwException::~mwException(void)"(??1mwException@@UAE@XZ

Error 8 errorLNK2019: unresolved external symbol _error_info_get_message_proxy referenced infunction "public: virtual char const * __thiscallmwException::what(void)const " (?what@mwException@@UBEPBDXZ)

Error 9 errorLNK2019: unresolved external symbol _array_ref_get_numeric_mxDouble_proxyreferenced in function "public: void __thiscall mwArray::GetData(double*,unsigned int)const " (?GetData@mwArray@@QBEXPANI@Z

Error 10 errorLNK2019: unresolved external symbol _array_ref_set_numeric_mxDouble_proxyreferenced in function "public: void __thiscall mwArray::SetData(double*,unsigned int)" (?SetData@mwArray@@QAEXPANI@Z

Error 11 errorLNK1120: 10 unresolved externals 

由于以上连接中采用的是32位,此操作系统为64位,MATLAB R2012a为64位,解决办法:

MATLAB R2012a与vs2010混合编程 error LNK2019MATLAB R2012a与vs2010混合编程 error LNK2019

打开配置管理器,如下:

MATLAB R2012a与vs2010混合编程 error LNK2019MATLAB R2012a与vs2010混合编程 error LNK2019

点击WIN32后的小按钮,点new,加入64位,如下图:

MATLAB R2012a与vs2010混合编程 error LNK2019MATLAB R2012a与vs2010混合编程 error LNK2019

后,单击确定,进行编译,即Build,成功编译。

若出现黑框后消失,Debug时选择Start WithoutDebugging,在DOS状态下运行,即可看到结果,如下图:

MATLAB R2012a与vs2010混合编程 error LNK2019MATLAB R2012a与vs2010混合编程 error LNK2019