英文:
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')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论