MATLAB: Using c-files in Matlab

c codeMATLABmex compiler

I would like to use a c-program in Matlab. It consists of several c-files. I have read several approaches, and also most of the examples I see is to write the c-code in a mex wrapper and compile it. What I want is to include these c-files in the mex file, and compile and link it. I also read about compiling them separately with a c-compiler and load the library. Does anyone have a clear set of instructions or directions on what would be the best way to go about this? Thanks a lot!

Best Answer

If these c files are already a library of functions and you wish to use more then one of them from MATLAB then make a shared library (dll) and use loadlibrary.
If these c files should be turned into a single function to be called by MATLAB or still need some work to combine together into something useable then I recommend creating a mex file.