level 6
nirvanლ
楼主
想请教一下如何利用C++编译的函数创建一个独立的可执行文件。找了帮助示例操作了一下,但是出现了问题,想知道是什么原因。我下的是Microsoft Visual C++2010Express学习版,是因为C++版本不支持,还是电脑的原因呢?
代码:
lopass = Compile[{{x, _Real, 1}, dt, RC},
Module[{a = dt/(RC + dt), yprev = First[x], yi},
Table[yi = a*x[[i]] + (1 - a)*yprev;
yprev = yi;
yi, {i, 1, Length[x]}]]];
targetDir = CreateDirectory[]
fnSource = FileNameJoin[{targetDir, "lopass.c"}];
Export[fnSource, lopass];
lopassmainSrcFile = FileNameJoin[{targetDir, "lopassMain.c"}];
Export[lopassmainSrcFile, lopassmainSrc, "Text"]
Needs["CCompilerDriver`"];
lopassExe =
CreateExecutable[{fnSource, lopassmainSrcFile}, "lowpass",
"TargetDirectory" -> targetDir,
"Libraries" -> "WolframRTL_Static_Minimal"]
参考:https://www.wolfram.com/mathematica/new-in-8/integrated-c-workflow/create-standalone-executables-using-compiled-funct.html



2020年08月09日 04点08分
1
代码:
lopass = Compile[{{x, _Real, 1}, dt, RC},
Module[{a = dt/(RC + dt), yprev = First[x], yi},
Table[yi = a*x[[i]] + (1 - a)*yprev;
yprev = yi;
yi, {i, 1, Length[x]}]]];
targetDir = CreateDirectory[]
fnSource = FileNameJoin[{targetDir, "lopass.c"}];
Export[fnSource, lopass];
lopassmainSrcFile = FileNameJoin[{targetDir, "lopassMain.c"}];
Export[lopassmainSrcFile, lopassmainSrc, "Text"]
Needs["CCompilerDriver`"];
lopassExe =
CreateExecutable[{fnSource, lopassmainSrcFile}, "lowpass",
"TargetDirectory" -> targetDir,
"Libraries" -> "WolframRTL_Static_Minimal"]
参考:https://www.wolfram.com/mathematica/new-in-8/integrated-c-workflow/create-standalone-executables-using-compiled-funct.html


