I want to run a matlab code in my c++ programme and wait for the results of Matlab and then continue to my c++ code. the problem is that the programme does not wait for matlab and continue their running. should I add anything to my code?
actually I tried to create process and used WaitForSingleObject.
int main()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
system("matlab.exe -nosplash -nodesktop -nodisplay -r run('Main')");
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
.
.
.
}
You probably need to use the option
to matlab instead of the option
Eg. see this page for more detail: https://www.mathworks.com/help/matlab/ref/matlabwindows.html
Additionally the
std::systemcall is 'standalone' - however you should check the return of the process launched.