Dear All, I am trying to create a mex file from several C++ source codes with .cpp and .h extensions. So far i have figured that i have to create a gateway routine by adding a mex function to one of source C++ codes and #include "mex.h". I want to create the gateway routine in my main.cpp (which is a C++ file which calls other functions from other source code files). I have tried creating my gateway routine in the following manner void mexFunction( int nlhs, mxArray plhs[], int nrhs, const mxArray *prhs[] ) { main ( );} int main ( ) {/ C++ code calling other .cpp functions */ } I get an error when i try to compile this in Visual C++ 2010 (I am doing this because i want to check if code works in C++ before creating mex files) that says error C3861: 'main': identifier not found.
I have tried embedding the main.cpp function in the mex function but C++ doesn't allow a local function to be embedded in another. I do not know C++ but have learnt a little these past few days from google. The original source codes compile in C++ and output a text file with results and is a console application. How do i create a successful MEX file from such source code? Any help is appreciated.
Best Answer