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

131 views Asked by At

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

There are 1 answers

4
Cris Luengo On

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')