Exception on debug C shared library based application when using visual studio 2017
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello guys,
Now, I try and study to use Matlab library compiler to convert matlab script to library function, and call it in C application.
Follow the tutorial in help, I could manage to compile and run the matrix example with mbuild tool (matlabroot\extern\examples\compilersdk\c_cpp\matrix).
Furthermore, I want to move another step to debug the program in visual studio. I configure the visual c++ as below post.
The visual studio could compile and run the executable correctly. But, the question now is I couldn't debug it correctly.
When I use single step debug, mclInitializeApplication(NULL,0) function will run very slowly, and debug output lots of exception message.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084520/image.png)
Exception thrown at 0x00007FFE9DCA9319 in matrix_exp_svr.exe: Microsoft C++ exception: mwboost::exception_detail::clone_impl<fl::filesystem::PathNotFound> at memory location 0x00000041850F9CA0.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084525/image.png)
If I ignored those exception, and try to step over libmatrixInitialize(),
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084530/image.png)
The program finally stop with the following exception.
Exception thrown at 0x000001B51C3303B4 in matrix_exp_svr.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
So, does anybody have met similar problem? Please share your insight, thanks a lot!
Jeff
5 comentarios
stomach
el 21 de Abr. de 2023
Hi, Poorren, did you solve this problem? I encountered the same problem that MATLAB shared library can not be debugged in visual studio.
stomach
el 21 de Abr. de 2023
I have found some information for this problem which says MATLAB shared library can not be built in debug mode.
Access Violation When Calling Library Function
The library file must be built in release mode, using a C++ compiler that MATLAB supports. If you build the library in debug mode, it might be incompatible with MATLAB, resulting in a termination of the program.
Respuestas (1)
stomach
el 21 de Abr. de 2023
More evidence has shown that it is impossible to debug the MATLAB shared library:
https://www.mathworks.com/matlabcentral/answers/93287-is-there-a-way-to-debug-a-matlab-compiler-4-0-r14-generated-executable
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Support for MinGW-w64 C/C++ Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!