Unhandled exception thrown when run connectMATLAB()
Show older comments
hi, I am currently building my c++ program running with Simulink. I have tried the code I found from the website: https://uk.mathworks.com/help/matlab/matlab_external/run-simulink-simulation-from-c.html
However, it seems I've some problem when I run this code :
std::unique_ptr<MATLABEngine> matlabPrt = connectMATLAB(session);
When I run connectMATLAB() it gives me unhandled exceptions:
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: std::runtime_error at memory location 0x00000098BA8FD678.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: mwboost::exception_detail::clone_impl<fl::filesystem::PathNotFound> at memory location 0x00000098BADFE670.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: mwboost::exception_detail::clone_impl<fl::filesystem::PathNotFound> at memory location 0x00000098BADFE930.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: foundation::core::except::Exception<MATLAB::engineAPI::SharedMatlabNotFound,std::exception,void> at memory location 0x00000098BADFF4D8.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: foundation::core::except::Exception<MATLAB::engineAPI::SharedMatlabNotFound,std::exception,void> at memory location 0x00000098BACFCFD0.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: matlab::engine::EngineException at memory location 0x00000098BACFD4D0.
Exception thrown at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: matlab::engine::EngineException at memory location 0x00000098BA8FEBF0.
Unhandled exception at 0x00007FFE495EA388 in ConsoleApplication1.exe: Microsoft C++ exception: matlab::engine::EngineException at memory location 0x00000098BA8FEBF0.
ID Managed ID Category Name Location
14072 0 Main Thread Main Thread msvcp140d.dll!__ExceptionPtr::_RethrowException
4436 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory
12540 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory
5392 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory
15404 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForAlertByThreadId
4120 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!LdrpCompareModuleBaseAddresses
It navigates me to the row 579 in the excptptr.cpp file.
I have no idea, what happen.
3 Comments
Enrico Zschau
on 15 Jan 2019
Moved: Rik
on 4 Jul 2023
Same problem here with Visual Studio 2015 Pro. With the former C interface using engOpen(), connection is done. With the C++ interface the exception occurs when cpp_engine_create_session(); is called from within ENGINE_FACTORY_IMPL.HPP.
Ausnahme ausgelöst bei 0x0000000000000000 in HCTest64D.exe: 0xC0000005: Zugriffsverletzung beim Ausführen an Position 0x0000000000000000.
Stack:
0000000000000000() Unbekannt
libMatlabEngine.dll!0000000180001378() Unbekannt
[Externer Code]
libMatlabEngine.dll!0000000180004d36() Unbekannt
HCLib64D.dll!`anonymous namespace'::initSession() Zeile 21 C++
HCLib64D.dll!matlab::engine::findMATLAB() Zeile 56 C++
HCLib64D.dll!matlab::engine::connectMATLABAsync() Zeile 80 C++
HCLib64D.dll!matlab::engine::connectMATLAB() Zeile 72 C++
...
I'm Using Matlab 2018b.
Stéphanie Monteiro
on 7 Jun 2021
Moved: Rik
on 4 Jul 2023
I have the same problem, did you find a solution?
Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!