I'm writing some MATLAB code, and I want to use some optimized C routines. I have the C source code, and it works just fine. I've created a MEX file and am capable of compiling it provided that it is in the same folder as the optimized C routines. However, I want to be able to distribute this code to others on various platforms. Since MEX files are binaries, each individual must (likely) recompile on their own machines. That is fine, but I want to make the process as painless as possible.
Currently, if all of the files are in the same directory, then calling something like
mex mexfile.c other1.o other2.o other3.o
from that directory works just fine as you would expect. For organizational purposes, however, I'd like for the C code to be in its own (sub)directory, say code. Unfortunately, if I structure things like this, the mex command errors out (the errors differ based on the different things that I've tried). I've tried things like
mex mexfile.c code/other1.o code/other2.o code/other3.o
and the -Ipathname and -Lfolder options on the mex command, but these haven't worked for me. I would think that there has to be a simple way to do what I'm wanting to do, but I just can't find the appropriate documentation or figure it out myself. Any help would be appreciated.
[OP's solution converted to answer below]
In the setup given above, using the following command works as desired for me:
mex -Icode mexfile.c code/other1.o code/other2.o code/other3.o
I stumbled across this solution while regenerating error messages.
I'm guessing that this is just the appropriate syntax for the -Ipathname option to the mex command, but I can't find documentation to support this conclusion. If anyone else can provide a link to actual documentation, that would certainly be better than a potential solution that just happened to work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With