E:\matlab\2012a-launch\extern\include
E:\matlab\2012a-launch\extern\lib\win64\microsoft
libmx.lib;libmex.lib;libeng.lib;
#include <iostream> #include <cmath> #include <string> #include <engine.h> using namespace std; int main(int argc, char** argv) { Engine* m_pEngine; m_pEngine = engOpen(NULL); if( m_pEngine == NULL ) { cout<<"error!"<<endl; exit(-1); } engEvalString(m_pEngine, "x=0:0.01:2*pi;"); engEvalString(m_pEngine, "y=sin(x);"); engEvalString(m_pEngine, "figure; plot(x,y,'g');"); system("pause"); engClose(m_pEngine); return 0; }
報錯:html
1)、沒法解析的外部符號 _engClose,該符號在函數 _main 中被引用 。ios
解決:換到x64c++
2)、沒法啓動此程序,由於計算機中丟失libeng.dll。嘗試從新安裝該程序以解決此問題。[3]編程
解決:E:\Program Files\MATLAB\R2013a\bin\win64 加入系統環境變量函數
參考:spa
[1] fourfire.c++,matlab混合編程[EB/OL].[2014-03-11].http://blog.sina.com.cn/s/blog_8e6bfecf0100y5ba.htmlcode
[2] justinlm.Visual Studio 2010 爲C/C++添加外部庫的方法[EB/OL].[2014-03-11]http://www.docin.com/p-156218299.htmlhtm
[3] hwby199106wHow_to_use_Matlab_Engine_in_Visual_Studio[EB/OL].[2014-03-11].http://www.doc88.com/p-458271665677.htmlblog