way1322 发表于 2006-5-15 21:50

[求助]用matcom生成.cpp文件后为何运行不了

我用matcom在VC下生成.cpp文件,但是在编译连接时都没错误,但最后在运行时出现这样的错误:<br>error:<STRONG>illegal fid.<br>called from d:\分开密钥\publickey.m 3<br><br>哪位高手大侠能帮我解决一下啊?毕业设计要用!!!</STRONG>
[此贴子已经被作者于2006-5-17 12:44:54编辑过]

way1322 发表于 2006-5-15 22:00

<P>怎么没人理啊~~~~~~~~~~</P>

happy 发表于 2006-5-16 08:27

回复:(way1322)[求助]用matcom生成.cpp文件后为何运...

<P>要嘛你把详细的错误信息贴出来<BR>要嘛你把程序贴出来<BR><BR>这样没头没尾的,没办法回答</P>

way1322 发表于 2006-5-16 14:31

回复:(happy)回复:(way1322)[求助]用matcom生成...

<P>这个是.m文件的主文件 名为publickey.m<br>clear<br>fid=fopen('mydata','r');<br>F=fread(fid);<br>m=char(F');<br>s=length(m);<br>=find(m==13);=find(m==10);%pm为回车换行位置<br>rho=input('请输入随机变量相关参数rho:');<br>X0=input('请输入随机变量初值X0:');<br>N=input('请输入随机序列长度值N:');<br>L=input('请输入加密位置L:');<br>X=gaus_mar(X0,rho,N);<br>y=X(L:L+s-1);<br>=sort(y);<br>=sort(g);<br>c=m(g)<br>p=c(f)<br><br>这个是名为gngauss.m的文件<br>function =gngauss(m,sgma)<br>if nargin == 0,<br>    m=0;sgma=1;<br>elseif nargin == 1,<br>    sgma=m; m=0;<br>end<br>u=rand;<br>z=sgma*(sqrt(2*log(1/(1-u))));<br>u=rand;<br>g1=m+z*cos(2*pi*u);<br>g2=m+z*sin(2*pi*u);<br><br><br>这是名为gaus_mar.m的文件<br>function =gaus_mar(X0,rho,N)<br>for i=1:2:N<br>    =gngauss;<br>end<br>X(1)=rho*X0+Ws(1);<br>for i=2:N<br>    X(i)=rho*X(i-1)+Ws(i);<br>end<br>    <br>用MATCOM在VC里翻译出来的程序是<br>这是g_publickey.cpp:<br><br>#include "matlib.h"<br>#pragma hdrstop<br><br>#include "publickey.h"<br><br>unsigned int mlibpr=mt_set_MT(0); // 1 if program is multithreaded, 0 otherwise.<br><br><br>int main() {<br>    begin_scope<br>    <br>    initM(MATCOM_VERSION);<br>    <br>    #include "publickey.cpp"<br>    <br>    exitM();<br>    return 0;<br>    end_scope<br>}<br><br>这是gaus_mar.cpp:<br>#include "matlib.h"<br>#pragma hdrstop<br><br>#include "gaus_mar.h"<br>#include "gngauss.h"<br><br><br><br>Mm gaus_mar(Mm X0, Mm rho, Mm N) {<br>    begin_scope<br>    X0.setname("X0"); rho.setname("rho"); N.setname("N"); <br>    dMm(X); dMm(i_); dMm(i_gaus_mar_v0); dMm(Ws); dMm(lhs_0); dMm(lhs_1); dMm(i_gaus_mar_v1); <br>    <br>    #line 1 "d:/公开单钥/gaus_mar.m"<br>    call_stack_begin;<br>    #line 1 "d:/公开单钥/gaus_mar.m"<br>    // nargin, nargout entry code<br>    double old_nargin=nargin_val; if (!nargin_set) nargin_val=3.0;<br>    nargin_set=0;<br>    double old_nargout=nargout_val; if (!nargout_set) nargout_val=1.0;<br>    nargout_set=0;<br>    <br>    // translated code<br>    <br>    #line 2 "d:/公开单钥/gaus_mar.m"<br>_   i_gaus_mar_v0 = colon(1.0,2.0,N); int i_gaus_mar_i0;<br>    for (i_gaus_mar_i0=0;i_gaus_mar_i0&lt;i_gaus_mar_v0.cols();i_gaus_mar_i0++) {<br>      forelem(i_,i_gaus_mar_v0,i_gaus_mar_i0);<br>      #line 3 "d:/公开单钥/gaus_mar.m"<br>_   /* = */gngauss(i_o,lhs_0,lhs_1); Ws(i_) = lhs_0; Ws(i_+1.0) = lhs_1;<br>      #line 4 "d:/公开单钥/gaus_mar.m"<br>    }<br>    #line 5 "d:/公开单钥/gaus_mar.m"<br>_   X(1.0) = rho*X0+Ws(1.0);<br>    #line 6 "d:/公开单钥/gaus_mar.m"<br>_   i_gaus_mar_v1 = colon(2.0,1.0,N); int i_gaus_mar_i1;<br>    for (i_gaus_mar_i1=0;i_gaus_mar_i1&lt;i_gaus_mar_v1.cols();i_gaus_mar_i1++) {<br>      forelem(i_,i_gaus_mar_v1,i_gaus_mar_i1);<br>      #line 7 "d:/公开单钥/gaus_mar.m"<br>_   X(i_) = rho*X(i_-1.0)+Ws(i_);<br>      #line 8 "d:/公开单钥/gaus_mar.m"<br>    }<br>    <br>    call_stack_end;<br>    <br>    // nargin, nargout exit code<br>    nargin_val=old_nargin; nargout_val=old_nargout;<br>    <br>    // function exit code<br>    X0.setname(NULL); rho.setname(NULL); N.setname(NULL); <br>    return X;<br>    end_scope<br>}<br><br>这是gngauss.cpp:<br>#include "matlib.h"<br>#pragma hdrstop<br><br>#include "gngauss.h"<br><br><br>Mm gngauss(Mm m, Mm sgma, i_o_t, Mm&amp; g1__o, Mm&amp; g2__o) {<br>    begin_scope<br>    m.setname("m"); sgma.setname("sgma"); <br>    dMm(g1); dMm(g2); dMm(u); dMm(z); <br>    <br>    #line 1 "d:/公开单钥/gngauss.m"<br>    call_stack_begin;<br>    #line 1 "d:/公开单钥/gngauss.m"<br>    // nargin, nargout entry code<br>    double old_nargin=nargin_val; if (!nargin_set) nargin_val=2.0;<br>    nargin_set=0;<br>    double old_nargout=nargout_val; if (!nargout_set) nargout_val=2.0;<br>    nargout_set=0;<br>    <br>    // translated code<br>    <br>    #line 2 "d:/公开单钥/gngauss.m"<br>_   if (istrue(nargin()==0.0)) {<br>      #line 3 "d:/公开单钥/gngauss.m"<br>_   m = 0.0;<br>      #line 3 "d:/公开单钥/gngauss.m"<br>_   sgma = 1.0;<br>      #line 4 "d:/公开单钥/gngauss.m"<br>    } else<br>    #line 4 "d:/公开单钥/gngauss.m"<br>    if (istrue(nargin()==1.0)) {<br>      #line 5 "d:/公开单钥/gngauss.m"<br>_   sgma = m;<br>      #line 5 "d:/公开单钥/gngauss.m"<br>_   m = 0.0;<br>      #line 6 "d:/公开单钥/gngauss.m"<br>    }<br>    #line 7 "d:/公开单钥/gngauss.m"<br>_   u = rand();<br>    #line 8 "d:/公开单钥/gngauss.m"<br>_   z = sgma*(msqrt(2.0*log(1.0/(1.0-u))));<br>    #line 9 "d:/公开单钥/gngauss.m"<br>_   u = rand();<br>    #line 10 "d:/公开单钥/gngauss.m"<br>_   g1 = m+z*cos(2.0*pi*u);<br>    #line 11 "d:/公开单钥/gngauss.m"<br>_   g2 = m+z*sin(2.0*pi*u);<br>    <br>    call_stack_end;<br>    <br>    // nargin, nargout exit code<br>    nargin_val=old_nargin; nargout_val=old_nargout;<br>    <br>    // function exit code<br>    m.setname(NULL); sgma.setname(NULL); <br>    g1__o=g1; g2__o=g2; <br>    return x_M;<br>    end_scope<br>}<br><br><br>Mm gngauss() {<br>    begin_scope<br>    double old_nargin=nargin_val; nargin_val=0.0; nargin_set=1;<br>    double old_nargout=nargout_val; nargout_val=1.0; nargout_set=1;<br>    dMm(m); dMm(sgma); dMm(g1__o); dMm(g2__o); <br>    gngauss(m, sgma, i_o, g1__o, g2__o);<br>    nargout_val=old_nargout;<br>    nargin_val=old_nargin;<br>    return(g1__o);<br>    end_scope<br>}<br><br>Mm gngauss(Mm m) {<br>    begin_scope<br>    double old_nargin=nargin_val; nargin_val=1.0; nargin_set=1;<br>    double old_nargout=nargout_val; nargout_val=1.0; nargout_set=1;<br>    dMm(sgma); dMm(g1__o); dMm(g2__o); <br>    gngauss(m, sgma, i_o, g1__o, g2__o);<br>    nargout_val=old_nargout;<br>    nargin_val=old_nargin;<br>    return(g1__o);<br>    end_scope<br>}<br><br>Mm gngauss(Mm m, Mm sgma) {<br>    begin_scope<br>    double old_nargin=nargin_val; nargin_val=2.0; nargin_set=1;<br>    double old_nargout=nargout_val; nargout_val=1.0; nargout_set=1;<br>    dMm(g1__o); dMm(g2__o); <br>    gngauss(m, sgma, i_o, g1__o, g2__o);<br>    nargout_val=old_nargout;<br>    nargin_val=old_nargin;<br>    return(g1__o);<br>    end_scope<br>}<br><br>Mm gngauss(i_o_t, Mm&amp; g1__o, Mm&amp; g2__o) {<br>    begin_scope<br>    double old_nargin=nargin_val; nargin_val=0.0; nargin_set=1;<br>    double old_nargout=nargout_val; nargout_val=2.0; nargout_set=1;<br>    dMm(m); dMm(sgma); <br>    gngauss(m, sgma, i_o, g1__o, g2__o);<br>    nargout_val=old_nargout;<br>    nargin_val=old_nargin;<br>    return x_M;<br>    end_scope<br>}<br><br>Mm gngauss(Mm m, i_o_t, Mm&amp; g1__o, Mm&amp; g2__o) {<br>    begin_scope<br>    double old_nargin=nargin_val; nargin_val=1.0; nargin_set=1;<br>    double old_nargout=nargout_val; nargout_val=2.0; nargout_set=1;<br>    dMm(sgma); <br>    gngauss(m, sgma, i_o, g1__o, g2__o);<br>    nargout_val=old_nargout;<br>    nargin_val=old_nargin;<br>    return x_M;<br>    end_scope<br>}<br><br><br>麻烦帮我看一下</P>
[此贴子已经被作者于2006-5-16 23:25:21编辑过]

way1322 发表于 2006-5-16 18:56

<P>happy教授!麻烦帮我看一下</P>

happy 发表于 2006-5-16 19:31

回复:(way1322)[求助]用matcom生成.cpp文件后为何运...

调用的时候设置头文件和库文件的路径了吗?

way1322 发表于 2006-5-16 23:22

回复:(happy)回复:(way1322)[求助]用matcom生成...

<P>是在环境变量那里设置的吧!那里我就设置好了!如果还要在别的地方设置的话,请告诉我好吗?</P>happy教授,麻烦帮我一下好吗?
[此贴子已经被作者于2006-5-18 3:43:51编辑过]

way1322 发表于 2006-5-18 03:45

happy教授!这是紧急求救啊!麻烦你了!!
页: [1]
查看完整版本: [求助]用matcom生成.cpp文件后为何运行不了