在Octave中,如何从多个C/C++源文件编译一个mex文件?

huangapple go评论44阅读模式
英文:

In Octave, how to compile a mex file from multiple C/C++ source files?

问题

在Matlab中,我们可以使用mex来编译一个包含多个文件(例如100个以上的.c文件)的库,方法如下:

mex *.c -o mylib.mex

但在Octave中,似乎只能接受一个输入源文件,它总是报错:

cc1.exe: fatal error: *.c: Invalid argument

已经尝试了很多搜索但没有找到解决方法。任何解决这个问题的指针将不胜感激。

英文:

In Matlab, we can use mex to compile a library from multiple files (e.g., 100+ .c files) using something like

mex *.c -o mylib.mex

But in Octave, it seems like that only one input source file accepted, it always gives an error

cc1.exe: fatal error: *.c: Invalid argument

Tried googing a lot and find no solution. Any pointer to getting this problem solved will be appreciated.

答案1

得分: 3

我认为Octave不会展开通配符,因此它不会将*.c识别为有效的文件名。

您可以明确列出所有源文件,如下所示:

files = dir('*.c');
files = {files.name};
mex(files{:}, '-o', 'mylib.mex')
英文:

I suppose that Octave doesn't expand the wildcard, so it doesn't recognize *.c as a valid file name.

You could explicitly list all the source files like this:

files = dir('*.c');
files = {files.name};
mex(files{:}, '-o', 'mylib.mex')

huangapple
  • 本文由 发表于 2023年7月12日 23:34:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76672265.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定