How to use generated matlab code (.h .dll .lib) in c++ program
6 次查看(过去 30 天)
显示 更早的评论
[EDIT: 20110608 10:06 CDT - reformat - WDR]
Dear All,
I wrote a function in matlab which multiply 3 by the input. And I have compiled it to .h .dll and .lib. Is there any tutorial about how to write code in C++ side?
This is my code:
#include <stdio.h>
#include "C:/Users/Administrator/Documents/MATLAB/test1/Untitled1/distrib/Untitled1.h"
#pragma comment( lib, "C:/Users/Administrator/Documents/MATLAB/test1/Untitled1/distrib/Untitled1.lib" )
int main()
{
double r[4] = {1,2,3,4};
double res[4];
mwArray a(1,1,mxDOUBLE_CLASS);
mwArray b(1,1,mxDOUBLE_CLASS);
a.SetData(r,4);
test(1,a,b);
b.GetData(res,4);
return 0;
}
1>------ Build started: Project: matlab_test, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>main.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>main.obj : error LNK2019: unresolved external symbol _mclcppGetLastError_proxy referenced in function "public: static void __cdecl mwException::raise_error(void)" (?raise_error@mwException@@SAXXZ)
1>main.obj : error LNK2019: unresolved external symbol _mclcppCreateError_proxy referenced in function "public: __thiscall mwException::mwException(void)" (??0mwException@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol _ref_count_obj_addref_proxy referenced in function "public: __thiscall mwException::mwException(class mwException const &)" (??0mwException@@QAE@ABV0@@Z)
1>main.obj : error LNK2019: unresolved external symbol _ref_count_obj_release_proxy referenced in function "public: virtual __thiscall mwException::~mwException(void)" (??1mwException@@UAE@XZ)
1>main.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>main.obj : error LNK2019: unresolved external symbol _array_ref_get_numeric_mxDouble_proxy referenced in function "public: void __thiscall mwArray::GetData(double *,unsigned int)const " (?GetData@mwArray@@QBEXPANI@Z)
1>main.obj : error LNK2019: unresolved external symbol _array_ref_set_numeric_mxDouble_proxy referenced in function "public: void __thiscall mwArray::SetData(double *,unsigned int)" (?SetData@mwArray@@QAEXPANI@Z)
1>C:\Users\Administrator\Documents\Visual Studio 2008\Projects\matlab_test\Debug\matlab_test.exe : fatal error LNK1120: 8 unresolved externals
1>Build log was saved at "file://c:\Users\Administrator\Documents\Visual Studio 2008\Projects\matlab_test\matlab_test\Debug\BuildLog.htm"
1>matlab_test - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deploy to C++ Applications Using MATLAB Data API (C++11) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!