[問題] 用C/C++呼叫MATLAB編好的lib可行嗎已回收
※ [本文轉錄自 C_and_CPP 看板]
作者: gaiger (hallowed be my name) 看板: C_and_CPP
標題: [問題] 用C/C++呼叫MATLAB編好的lib可行嗎
時間: Mon Nov 16 13:56:53 2009
想把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
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.102.251
推
11/16 21:27, , 1F
11/16 21:27, 1F