function compile() % mystr1 sets up the environmental variables % x64 specifies platform (remove that flag if you want to compile with 32-bit, % specifying correct platform is important to be consistent with "mex" compiler) % /openmp flag indicates, that there are omp compiler directives mystr1 = '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64 & cl /c /EHsc /MDd /openmp '; mycommand = ['!', mystr1, 'omp_file.cpp']; eval(mycommand); mycommand = ['mex ', 'mexme.cpp ', 'omp_file.obj']; eval(mycommand);