Is mclRunMain necessary?

조회 수: 2 (최근 30일)
hnde
hnde 2011년 2월 21일
Hello,
Most of the examples on calling C++ shared libraries have the format:
int main()
{
mclmcrInitialize();
return mclRunMain((mclMainFcnType)run_main,0,NULL);
}
int run_main(int argc, char **argv)
{
if (!mclInitializeApplication(NULL,0))
{
std::cerr << "could not initialize the application properly"
<< std::endl;
return -1;
}
if( !mylibInitialize() )
{
std::cerr << "could not initialize the library properly"
<< std::endl;
return -1;
}
else
{
try
{
mwArray a(5);
myfunc(a);
}
mylibTerminate();
}
mclTerminateApplication();
return 0;
}
I was just wondering if it would be ok to omit mclRunMain function, and just do everything in main, like this:
int main()
{
mclmcrInitialize();
if (!mclInitializeApplication(NULL,0))
{
std::cerr << "could not initialize the application properly"
<< std::endl;
return -1;
}
if( !mylibInitialize() )
{
std::cerr << "could not initialize the library properly"
<< std::endl;
return -1;
}
else
{
try
{
mwArray a(5);
myfunc(a);
}
mylibTerminate();
}
mclTerminateApplication();
return 0;
}
Thank you.

답변 (1개)

Peter Webb
Peter Webb 2011년 3월 22일
You need mclRunMain on the Macintosh, and if you're using MATLAB Graphics. Otherwise you can probably do without it.
  댓글 수: 1
hnde
hnde 2011년 3월 23일
Thank you for your answer.
I am using windows. And I am also using Matlab Graphics. Would I still need it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by