Compiling a MEX file using object files in another folder

I am writing MATLAB code and I want to use some optimized C routines. I have C source code and it works fine. I created a MEX file and can compile 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 different platforms. Since MEX files are binary files, everyone should (probably) recompile their own machines. This is great, but I want to make the process as painless as possible.

Currently, if all the files are in the same directory, then it calls something like

mex mexfile.c other1.o other2.o other3.o

from this directory it works as well as you would expect. However, for organizational purposes, I would like the C code to be in its own (auxiliary) directory, say code. Unfortunately, if I structure these things, the command mexfixes the errors (the errors vary depending on what I tried). I tried things like

mex mexfile.c code/other1.o code/other2.o code/other3.o

and -Ipathnameand -Lfolderas a team mex, but they did not work for me. I would think that there should be an easy way to do what I want to do, but I just cannot find the relevant documentation or understand it myself. Any help would be appreciated.

+3
source share
2 answers

[OP solution converted to answer below]

:

mex -Icode mexfile.c code/other1.o code/other2.o code/other3.o

, .

, -Ipathname mex, . - , , , , , .

+1

-

emlc -I './somedir/' -o sourcefilemex -T mex sourcefile

-T, mex- C. .

0

All Articles