作者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
※ gaiger:转录至看板 MATLAB 11/16 15:00