[問題] 用C/C++呼叫MATLAB編好的lib可行嗎
看板C_and_CPP (C/C++)作者gaiger (hallowed be my name)時間16年前 (2009/11/16 13:56)推噓0(0推 0噓 0→)留言0則, 0人參與討論串1/1
想把MATLAB自代的函式編成lib給C/C++呼叫,現把問題簡化如下:
寫個很蠢的MABLIB code :
=====
function y = test1(N)
y = [1:N] ;
=====
想把這code轉成dll/lib給C/C++呼叫:爬了文/問了谷歌:
http://www.vckbase.net/document/viewdoc/?id=1548
http://info.codepub.com/2008/08/info-20908.html
(我是用VC 2005 + MATLAB2007b)
照他上面設定的做:
>> mcc -W lib:test1 -T link:lib test1.m
跑出 test1.dll, test1.lib test1.h test1.c test1_mcc_component_data.c
然後vc裡面就使用 test1.lib 並include test1.h test1.c test1_mcc_component_data.c
再包一個main :
#include "test1.h"
int main(void)
{
test1Initialize();
}
然後按下play鍵,VC就會說 : 找不到指定的程序: Unhandled exception at 0x7c986668 in MAT2C.exe: 0xE06D7363: Microsoft C++
Exception.(看樣子是內存錯誤)
我想問 要怎做才可以用C去呼叫MATLAB做好的lib呢?
爬文有看到MRC這東西 但我不是要把MATLAB包成exe給別台沒有MATLAB的電腦用啊。。
有神人知道怎做嗎 謝謝。
然後加個
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.102.251
※ gaiger:轉錄至看板 MATLAB 11/16 15:00
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章