How do I debug DLL code in Visual Studio after using loadlibrary in MATLAB?
I have a C++ code that I have compiled in Visual Studio 2022 as a DLL. I use MATLAB to call the DLL using the function loadlibrary. The code executes no problem. However, I want to enter the Visual Studio debugger to step through the code once MATLAB calls the DLL. Years ago in a previous version of Visual Studio and MATLAB, a friend showed me how to connect Visual Studio to MATLAB. In Visual Studio, I would select "Build->Attach to process" and pick the MATLAB process that would appear in the window. Then, I could add a breakpoint in the C code, and when MATLAB called the DLL, the Visual Studio debugger would stop code execution at the break point and let me step through the code. I’m unable to do that now for some reason. When I attach MATLAB to Visual Studio, the breakpoint turns to an empty red outline circle with a caution triangle on it. When I hover over it, the tooltip says "The breakpoint will not currently be hit. No symbols have been loaded for this document." The Symbol Status column of the Debug->Windows->Modules dialog says "Cannot find or open the PDB file." I’m unsure what to do here. I’m sure I’m just forgetting a step that I was shown years back. Any help would be appreciated. Note Visual Studio did create a pdb file along with the DLL and both are in the same directory. Also, I compiled in debug mode, not release mode.I have a C++ code that I have compiled in Visual Studio 2022 as a DLL. I use MATLAB to call the DLL using the function loadlibrary. The code executes no problem. However, I want to enter the Visual Studio debugger to step through the code once MATLAB calls the DLL. Years ago in a previous version of Visual Studio and MATLAB, a friend showed me how to connect Visual Studio to MATLAB. In Visual Studio, I would select "Build->Attach to process" and pick the MATLAB process that would appear in the window. Then, I could add a breakpoint in the C code, and when MATLAB called the DLL, the Visual Studio debugger would stop code execution at the break point and let me step through the code. I’m unable to do that now for some reason. When I attach MATLAB to Visual Studio, the breakpoint turns to an empty red outline circle with a caution triangle on it. When I hover over it, the tooltip says "The breakpoint will not currently be hit. No symbols have been loaded for this document." The Symbol Status column of the Debug->Windows->Modules dialog says "Cannot find or open the PDB file." I’m unsure what to do here. I’m sure I’m just forgetting a step that I was shown years back. Any help would be appreciated. Note Visual Studio did create a pdb file along with the DLL and both are in the same directory. Also, I compiled in debug mode, not release mode. I have a C++ code that I have compiled in Visual Studio 2022 as a DLL. I use MATLAB to call the DLL using the function loadlibrary. The code executes no problem. However, I want to enter the Visual Studio debugger to step through the code once MATLAB calls the DLL. Years ago in a previous version of Visual Studio and MATLAB, a friend showed me how to connect Visual Studio to MATLAB. In Visual Studio, I would select "Build->Attach to process" and pick the MATLAB process that would appear in the window. Then, I could add a breakpoint in the C code, and when MATLAB called the DLL, the Visual Studio debugger would stop code execution at the break point and let me step through the code. I’m unable to do that now for some reason. When I attach MATLAB to Visual Studio, the breakpoint turns to an empty red outline circle with a caution triangle on it. When I hover over it, the tooltip says "The breakpoint will not currently be hit. No symbols have been loaded for this document." The Symbol Status column of the Debug->Windows->Modules dialog says "Cannot find or open the PDB file." I’m unsure what to do here. I’m sure I’m just forgetting a step that I was shown years back. Any help would be appreciated. Note Visual Studio did create a pdb file along with the DLL and both are in the same directory. Also, I compiled in debug mode, not release mode. dll, visual-studio, debug, loadlibrary MATLAB Answers — New Questions