Link Error while using Matlab R2013a in MS VC++ 2013

I am writing a BCI game application in VC++ and require to implement Common Spatial Pattern Filtering (CSP) for feature extraction. Due to the hefty coding involved, I prefer to use an existing CSP Matlab function that I have. I followed the steps as given in: http://herohuyongtao.blogspot.hk/2012/04/matlabc-cmatlab.html
However, when building the project, I encounter the following:
1>------ Build started: Project: Test4, Configuration: Debug Win32 ------
1>test.obj : error LNK2019: unresolved external symbol _mclInitializeApplication_proxy referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mclTerminateApplication_proxy referenced in function __catch$_main$0
1>test.obj : error LNK2019: unresolved external symbol _ref_count_obj_addref_proxy referenced in function "protected: __thiscall mwArray::mwArray(class array_ref *,bool)" (??0mwArray@@IAE@PAVarray_ref@@_N@Z)
1>test.obj : error LNK2019: unresolved external symbol _ref_count_obj_release_proxy referenced in function "public: virtual __thiscall mw_auto_ptr_t<class char_buffer>::~mw_auto_ptr_t<class char_buffer>(void)" (??1?$mw_auto_ptr_t@Vchar_buffer@@@@UAE@XZ)
1>test.obj : error LNK2019: unresolved external symbol _char_buffer_get_buffer_proxy referenced in function "public: __thiscall mwString::operator char const *(void)const " (??BmwString@@QBEPBDXZ)
1>test.obj : error LNK2019: unresolved external symbol _array_ref_to_string_proxy referenced in function "public: class mwString __thiscall mwArray::ToString(void)const " (?ToString@mwArray@@QBE?AVmwString@@XZ)
1>test.obj : error LNK2019: unresolved external symbol _array_ref_getV_int_proxy referenced in function "public: class mwArray __cdecl mwArray::GetPromoted(unsigned int,...)" (?GetPromoted@mwArray@@QAA?AV1@IZZ)
1>test.obj : error LNK2019: unresolved external symbol _array_ref_set_numeric_mxInt32_proxy referenced in function "public: class mwArray & __thiscall mwArray::operator=(int const &)" (??4mwArray@@QAEAAV0@ABH@Z)
1>test.obj : error LNK2019: unresolved external symbol _error_info_get_message_proxy referenced in function "public: virtual char const * __thiscall mwException::what(void)const " (?what@mwException@@UBEPBDXZ)
1>test.obj : error LNK2019: unresolved external symbol _mclcppGetLastError_proxy referenced in function "public: static void __cdecl mwException::raise_error(void)" (?raise_error@mwException@@SAXXZ)
1>test.obj : error LNK2019: unresolved external symbol _mclcppCreateError_proxy referenced in function "public: __thiscall mwException::mwException(class error_info *,bool)" (??0mwException@@QAE@PAVerror_info@@_N@Z)
1>test.obj : error LNK2019: unresolved external symbol _mclGetMatrix_proxy referenced in function "public: __thiscall mwArray::mwArray(unsigned int,unsigned int,enum mxClassID,enum mxComplexity)" (??0mwArray@@QAE@IIW4mxClassID@@W4mxComplexity@@@Z)
1>test.obj : error LNK2019: unresolved external symbol _libmyadd2Initialize referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libmyadd2Terminate referenced in function __catch$_main$0
1>test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl myadd2(int,class mwArray &,class mwArray &,class mwArray const &,class mwArray const &)" (__imp_?myadd2@@YAXHAAVmwArray@@0ABV1@1@Z) referenced in function _main
1>D:\Test4\Debug\Test4.exe : fatal error LNK1120: 15 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Could anyone plz tell me how to fix this? Any comments would be appreciated.

2 个评论

Aresh - it seems that there are some missing libraries. What is the line that builds the project?
Thank you Geoff for your help. This is a screenshot of my project:
I am just trying to redo the myadd2 example posted on: http://herohuyongtao.blogspot.hk/2012/04/matlabc-cmatlab.html
My settings are as follows:
1. In the Solution Explorer, right-click Test4->Properties->Configuration Properties->VC++ Directories->Include Directories-> Add "C:\Program Files\MATLAB\R2013a\extern\include".
2. Similarly, VC++ Directories->Library Directories-> Add "C:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft".
3. Linker->General->Additional Library Directories->Add "C:\Program Files\MATLAB\R2013a\extern\include".
Linker->Input->Additional Dependencies-> Add the following:
On pressing F7, I get the following errors:
I have attached these screenshots for clarity. Could you plz tell me what is missing? Thank you in advance.

请先登录,再进行评论。

回答(1 个)

Aresh - I think that your settings (as given above) are not quite correct. You mention that you added the following directories
  • "C:\Program Files\MATLAB\R2013a\extern\include".
  • "C:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft".
  • "C:\Program Files\MATLAB\R2013a\extern\include".
If you look back at http://herohuyongtao.blogspot.hk/2012/04/matlabc-cmatlab.html, sections 2 and 3, the author indicates how you must install the MATLAB Compiler Runtime (MCR) on the PC (section 2) and then add the following libraries (section 3)
  • Add MATLAB Compiler Runtime include folder to project Include files: i.e. C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\extern\include.
  • Add MATLAB Compiler Runtime library folder to project Library files: i.e. C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\extern\lib\win64\microsoft.
  • Add MATLAB Compiler Runtime binary folder to project Debugging>Environment: i.e. PATH=%PATH%;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\runtime\win64;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\bin\win64.
These folders are slightly different than the ones that you have added as they correspond to the MCR rather than the (base) MATLAB folders.
Ensure that you have downloaded the correct (64-bit, 2013a) MCR from Compiler Runtime (MCR), add the include and lib folders that correspond to the MCR as shown above, and try to recompile the code.

类别

在 帮助中心 和 File Exchange 中查找有关 Deploy to C++ Applications Using mwArray API (C++03) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by