MATLAB: How to covert a c code to a MEX file

covert a c code to a mexmex

Hi, I'm trying to convert a simple c code to a MEX file.I used the following command.
mex c_code.c
But it gives the following error.
c:\users\abrew\appdata\local\temp\mex_vgaoax\c_code.obj: multiple definition of _main
first definition is in file
c:\progra~2\matlab\r2008a\sys\lcc\lib\libcrt0.obj
Specified export _mexFunction is not defined
Missing exports. Aborting
C:\PROGRA~2\MATLAB\R2008A\BIN\MEX.PL: Error: Link of 'c_code.mexw32' failed.
??? Error using ==> mex at 207
Unable to complete successfully.
Can anyone help me to solve this issue.

Best Answer

You should read the documentation on creating and compiling mex functions. You need a special interface function (mexFunction). E.g., you can start here for instructions and examples:
Related Question