[問題] VS2010用Matlab的shared library

看板C_and_CPP (C/C++)作者 (自由與自閉)時間13年前 (2012/09/04 08:12), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
我不知道VS2010環境設置有什麼問題 我試著跑Matlab提供的一個shared library的範例 用Matlab產生了libmatrix.dll, libmatrix.lib, libmatrix.h 在主程式.cpp中要使用libmatrix.dll libmatrix.h中include了mclmcrrt.h(matlab提供) mclmcrrt.h中又include了很多其他headfile(matlab提供) 我也在VC++ directories中增加了matlab存放所有inlcude和lib的folder 但我debugs時出現 Error 1 error C2065: 'mwArray' : undeclared identifier c:\users\jean\documents\my dropbox\research\code\spde_test_c\matrixdriver\matrixdriver\matrixdriver.cpp 43 1 matrixdriver 等一系列Errro mwArray是定義在mclmcrrt.h裡所include的matrix.h 我不懂為什麼他可以順利採用mclmcrrt.h內定義的變數 卻無法採用同資料夾內的其他.h檔定義的變數 /*============================================================== * * MATRIXDRIVER.CPP * Sample driver code that calls a C++ shared library created using * the MATLAB Compiler. Refer to the MATLAB Compiler documentation * for more information on this * * This is the wrapper CPP code to call a shared library created * using the MATLAB Compiler. * * Copyright 1984-2007 The MathWorks, Inc. * *============================================================*/ // Include the library specific header file as generated by the // MATLAB Compiler #include "libmatrix.h" int run_main(int argc, char **argv) { // Call application and library initialization. Perform this // initialization before calling any API functions or // Compiler-generated libraries. if (!mclInitializeApplication(NULL,0)) { std::cerr << "could not initialize the application properly" << std::endl; return -1; } if( !libmatrixInitialize() ) { std::cerr << "could not initialize the library properly" << std::endl; return -1; } else { try { // Create input data double data[] = {1,2,3,4,5,6,7,8,9}; mwArray in1(3, 3, mxDOUBLE_CLASS, mxREAL); mwArray in2(3, 3, mxDOUBLE_CLASS, mxREAL); in1.SetData(data, 9); in2.SetData(data, 9); // Create output array mwArray out; // Call the library function addmatrix(1, out, in1, in2); // Display the return value of the library function std::cout << "The value of added matrix is:" << std::endl; std::cout << out << std::endl; multiplymatrix(1, out, in1, in2); std::cout << "The value of the multiplied matrix is:" << std::endl; std::cout << out << std::endl; eigmatrix(1, out, in1); std::cout << "The eigenvalues of the first matrix are:" << std::endl; std::cout << out << std::endl; } catch (const mwException& e) { std::cerr << e.what() << std::endl; return -2; } catch (...) { std::cerr << "Unexpected error thrown" << std::endl; return -3; } // Call the application and library termination routine libmatrixTerminate(); } int main() { mclmcrInitialize(); return mclRunMain((mclMainFcnType)run_main,0,NULL); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 141.212.126.202
文章代碼(AID): #1GHKTbDN (C_and_CPP)
文章代碼(AID): #1GHKTbDN (C_and_CPP)