I have an *.exe project that was written in one solution under vs2005 and i have a DLL file
that the *.exe project is using.
the problem is that the dll was written in adiffrent solution and when i try to make attach
to the *.exe file (after i run it) from the dll solution in order to debug the dll , i get no symbols are loaded error (and i cant debug the dll) altough symbols were loaded (i can see the *.pdb files that created after i compiled the dll solution) .
What can I do?
First check the Output window, it will show whether or not it could find debugging symbols for the DLL when it got loaded. Next, switch to Debug + Windows + Modules, right-click your DLL and choose "Symbol load information". That shows where the debugger looked for .pdb files for the DLL. Ensure the .pdb is located in one of these paths.
If the problem is not getting source code for the DLL instead of missing .pdb files, first delete the hidden .suo file in the solution directory. The next time you debug into the DLL, Visual Studio will again prompt you to provide the path to the source code file. Don't press Escape, enter the path. Another thing you can do is right-click the solution in the Solution Explorer window, Properties, Common Properties, Debug Source Files. Add the path to the DLL source code directory.
If you have the visual studio project that generates the dll, compile it in debug configuration and launch debug. You'll be asked for an executable ; select the one you have (from your other solution) and you'll be able to debug the dll.
Now if you want to debug both at once, i believe your way is correct, as long as the dll that the exe uses is the exact one that you've just compiled in your other solution. That might be the problem you're encountering.
Related
I copied an existing project and renamed the folder. Now I get this error when I try to compile the application
debugging information cannot be found or does not match. No symbols loaded.
Do you want to continue debugging ?
If I click yes, it compiles and runs fine. But now I have to deal with that message. Just curious about what I change in the projects properties to get it to stop.
You probably have deactivated the debugging information for your project:
Right click on your project -> Properties
Configuration properties -> Linker -> Debugging
Switch "Generate Debug Info" from No to Yes
Rebuild your project and retry, it should now run without the message :)
The main reason is that you don't have a matching pdb and exe.
Some possible solutions:
You are compiling in release instead of debug
You need to clean/build or rebuild
You don't have your pdb files being generated in the same directory as the exe
You have a mismatching pdb, maybe the copied source is newer than today's date and something isn't building properly.
Try cleaning out all debug object files
You are attaching to a process that you started from a different location from where your build exe and pdb exist
Restart Visual Studio
This happens to me every now and then, while debugging code and making changes it seems like visual studio caches the pdb information and sometimes it gets stuck. Doing a Rebuild solution, deleting the pdb and creating a new one doesn't fix the problem.
Of course I do have the generate debug information on and all that it's needed, specially since this happens while debugging the code several times.
Visual Studio seems to be happy with the in-memory pdb and refuses to update it, regardless of time-stamps or even size changes in the pdb.
The only way to reset this is to exit Visual Studio (the IDE) and restart it again.
In some rare occurrences, the IDE might be still running in the background (process explorer shows it there) and might hold the handle to the file open. You can kill the process before restarting the IDE.
Good Luck
I just encountered this error in VS2012. It is definitely caused by a bug in Visual Studio, which reveals itself in situations when the local PDB file of the main project has the same name as the final PDB file for the entire executable (even if the two are located in different directories!)
Consider this example.
Solution consists of three projects: main, a, and b. main is the top-level project for the executable, while a and b are libraries linked into main.
In all three projects $(IntDir) variable is set to $(SolutionDir)\$(Configuration)\$(ProjectName)\. This means that project main dumps its intermediate files to Debug\main\, project a - to Debug\a\ and so on.
In C/C++ -> Output Files settings all three projects have Program Database File Name value set to $(IntDir)$(TargetName).pdb. This means that project main generates its local PDB file as Debug\main\main.pdb, project b as Debug\b\b.pdb and so on.
Finally, in Linker -> Debugging settings of project main the Generate Program Database File value is set to $(OutDir)$(TargetName).pdb. This means that the global PDB file for the entire executable will be generated as Debug\main.pdb.
Note that in this setup each PDB file is generated in its own, separate directory.
In this setup you will get Debugging information cannot be found or does not match error if you attempt to run the program under the debugger. And if you take a look at the Debug\main.pdb file (which will exist), you will notice that it is exactly the same as Debug\main\main.pdb file! I.e. somehow the local PDB for main managed to overwrite what was supposed to be the global PDB for the final executable. I.e. the debugger is right to complain that the PDB file is "wrong". It is indeed wrong.
Again, in the above setup the final global PDB somehow gets overwritten by local PDB of the top project. I don't know why it happens. It appears to be a bug. (Note that even though these PDB files have the same name, they are generated in different directories, i.e. they should not conflict.)
A workaround that fixes this issue is to give the local PDB of project main a different name. For example, just go to C/C++ -> Output Files for the main project and change Program Database File Name value to $(IntDir)$(TargetName)_local.pdb (or to $(IntDir)12345.pdb if you so desire). This will eliminate the conflict and solve the problem.
Enable PDB creation by:
Right click on MyProject > Properties > Debugging:
C/C++ > General > Debug Information Output = Program Database (/Zi)
Linker > Debugging > Generate Debug Info = Yes (/DEBUG)
Clean MyProject, restart Visual Studio (just to be sure), rebuild MyProject.
The output folder should then contain *.pdb files.
If you debug optimized/release code consider switching off optimization via
C++ > Optimization > Optmization = Disabled (/Od)
I faced the same problem and tried all above mentioned solutions but it couldn't help me.
Then I found a new solution randomly and it worked.
Solution is that,in case you are having many projects in a solution then you should mark any one (specific one which you have to decide) project as a "Set as Startup Project".
Right click on that specific project and click "Set as Startup Project".
It worked for me.
The pdb or Program Database file appears to be missing (basically, the path has changed and can no longer be found by the compiler). See this related post for additional information.
I had a similar problem and the reason was that I had run one of the projects of my solution in a different process and that process couldn't be killed. I didn't think much of it. So when I was building the solution in a separate environment one of the pdb files didn't match so at the end I couldn't load any of the pdb files. I just restarted my computer and that fixed it.
Good luck
Restarting Visual Studio can fix one instance of this problem.
Right click on your project in the solution browser => Clean => Build.
That is if your build generates a .pdb at all (look in your target dir)
If not, you should enable debug by the steps mentioned in other posts
Most probably there are other reasons like .pdb / .exe file mismatch, something were not built / rebuilt, but I had similar case in Visual studio 2013 -
Something to do with virtual inline function - so I suspect.
In my case debugger were jumping in a middle of another C++ function, not the one which was called. Jump was off source code by 11 source code lines, but I cannot explain why much miscalculation happened. By simple rearranging functions I've got rid of this problem.
May be needs more detailed analysis why 11 lines shift happened originally.
Haven't seen this kind of behavior in any other visual studio.
This problem has bothered me for a long time. AnT's anwser is very helpful. The main idea is Don't have any two pdb files have the same name, even they are not in the same directory.
This is my situation: I have tow projects name "FooBar" and "FooBarDll", the first one is an exe, and the second one is a dll. I set both projects Target Name to be "FooBar", so that they will generate "FooBar.exe" and "FooBar.dll" respectively.
Then I set
"General -> Intermediate Directory" to be "$(OutDir)\$(ProjectName)\"
"C/C++ -> Output Files -> Program Database File Name" to be "$(IntDir)$(TargetName).pdb"
"Linker -> Debugging -> Generate Program Database File" to be "$(OutDir)$(TargetName).pdb"
So I get these files:
Debug\FooBar.exe
Debug\FooBar.pdb //C++ pdb
Debug\FooBar\FooBar.pdb //Linker pdb
Debug\FooBar.dll
Debug\FooBar.pdb // C++ pdb again!
Debug\FooBarDll\FooBar.pdb // Linker pdb
My solution is replacing every "TargetName" with "ProjectName", then I will get:
Debug\FooBar.exe
Debug\FooBar.pdb //C++ pdb
Debug\FooBar\FooBar.pdb //Linker pdb
Debug\FooBar.dll
Debug\FooBarDll.pdb // C++ pdb
Debug\FooBarDll\FooBarDll.pdb // Linker pdb
Then there is no conflict!
Give C/C++ pdb a suffix may be better, like: "C/C++ -> Output Files -> Program Database File Name" to be "$(IntDir)$(ProjectName)_C.pdb"
I had the same issue, and this link helped me solved the problem, by rename "symsrv.no" to "symsrv.yes" in VS IDE folder.
Curious, it happens to me that I needed to change the folder name from:
...\Custom Librarry (MyDll.dll(
to
...\Custom Librarry (MyDll.dll)
just by closing the parenthesis it worked !
The project runs okay in the debug mode of Visual Studio, but when I tried to double-click the exe generated, it says some dll is missing. When I copied the missing dll beside the exe and double-click again, no error message dialog appeared but also nothing happened(the project has Qt-based GUI and reference some external png files).
How does Visual Studio run the exe ? How can I run the exe on my own ? Should I create a installer for the project to make it run on other computers?
you would need to either build statically or provide the required dll files.
the page at http://www.tapkaa.com/2013/05/what-dll-files-are-required-to-run-an-application-developed-with-visual-c/ tells how you can find the missing dll files.
When a process needs to load a DLL by name (without a full path to it), it will check several different places. One of those places may be the current working directory. (The details of the search path are complicated by history and security issues. You can learn the details by looking up LoadLibrary and SetDllDirectory on MSDN.)
In Visual Studio, if you look at the Properties page for the project, and click the Debugging tab, you'll see what directory is set as the working directory when you launch the program from Visual Studio. When you double click on an icon, I believe the working directory will be the directory of the executable file. If these are different, that could explain why you're able to find the DLL in one case but not in the other.
If you're calling LoadLibrary directly, the best thing to do is to always give the full path to the library. Typically, you GetModuleFileName to find out the full path for the executable, then replace the filename portion with the name of the DLL or a relative path from the executable to the DLL.
If you're failing to load an implicitly-linked DLL, then you probably need to make sure your DLL is in the same directory as the executable file.
I've specified symbol (pdb) file inside 2010 so that it is loaded correctly but I get the No source available error and the Browse to Find Source Code is greyed out. Does anyone know how I can specify the source code directory or look inside the pdb to find out where it is?
EDIT: My DLL is being called by an external program. The error is happening inside my DLL so I have the source code. When the error occurs I click Debug, the pdb symbols are loaded but not the source.
If you moved the DLL from its build directory then the debugger is unlikely to be able to find the source code files itself. First thing you can do is to right-click the Solution root node in the Solution Explorer window, Properties, Common Properties, Debug Source Files and add the path to the DLL project source directory.
Second way: the debugger prompts you the first time it needs to find a source code file. If you ever clicked Cancel on that dialog, pretty common thing to do when you don't know what it is really asking, then the IDE remembers your selection and won't prompt you again. Fix that by deleting or renaming the hidden .suo file in the solution directory.
From what I understand you just want to debug your program, that you have in form of DLL. The problem is that external program uses this DLL and you click "Debug" from the window that pops up after the error occurs.
I assume you want to open your project in Visual Studio and then press Ctrl + Alt + P to open "Attach to Process" window, where you should select process that uses this DLL (iexplore.exe or whatever you are working with) so that you can toggle some breakpoints there and see what's going on before the error occurs.
The hack by #Hans Passant works, but there's actually an official way to achieve this: right click your solution at the solution explorer, select properties / Common Properties / Debug source files. You should be able to see and edit a list of all files where you previously selected 'cancel' when prompted for a source path.
I have to debug multiple dlls each within their own project. There is a parent executable that loads a dll, which serves as a container for the other dlls.
My question is how can I debug the whole 'component' ie: all the dll's involved, using Visual Studio 2005 for C++.
If they're all in the same solution, set a breakpoint in the DLL project where you want to debug, right click on the EXE project, and select Debug > Start new instance.
If they're in separate solutions, open the DLL solution, right click on the project, expand the Configuration Properties node in the tree on the left, select Debugging. Set the Command property to point to the debug build of the EXE in the other project. Then set your breakpoint(s) and hit F5 to start debugging.
Arbitrarily pick one of the DLL projects as the startup project, it doesn't matter which. Right-click + Properties, Debugging. Set the 'Command' setting to the path of a test EXE that will load the DLLs. If you don't have a good one then just write one, might as well add it to the project and make it the startup project.
Pay attention to the Output window while the EXE starts. You'll see notifications for each DLL that gets loaded. As soon as one of the DLLs that's in your solution gets loaded then the debugger jumps in, looks for the .pdb file for the DLL and activates any breakpoints you'd have set in the DLL source code. You cannot debug the DLL unless the EXE loads it.
If that still doesn't enable breakpoints then use Debug + Windows + Modules and locate the DLL in the list. Right-click it and choose Symbol Load Information to find out where the debugger looked for the .pdb file. This doesn't go wrong very often since the DLL contains the path to the .pdb file. The far more typical failure mode is that the EXE simply didn't load the DLL.
I copied an existing project and renamed the folder. Now I get this error when I try to compile the application
debugging information cannot be found or does not match. No symbols loaded.
Do you want to continue debugging ?
If I click yes, it compiles and runs fine. But now I have to deal with that message. Just curious about what I change in the projects properties to get it to stop.
You probably have deactivated the debugging information for your project:
Right click on your project -> Properties
Configuration properties -> Linker -> Debugging
Switch "Generate Debug Info" from No to Yes
Rebuild your project and retry, it should now run without the message :)
The main reason is that you don't have a matching pdb and exe.
Some possible solutions:
You are compiling in release instead of debug
You need to clean/build or rebuild
You don't have your pdb files being generated in the same directory as the exe
You have a mismatching pdb, maybe the copied source is newer than today's date and something isn't building properly.
Try cleaning out all debug object files
You are attaching to a process that you started from a different location from where your build exe and pdb exist
Restart Visual Studio
This happens to me every now and then, while debugging code and making changes it seems like visual studio caches the pdb information and sometimes it gets stuck. Doing a Rebuild solution, deleting the pdb and creating a new one doesn't fix the problem.
Of course I do have the generate debug information on and all that it's needed, specially since this happens while debugging the code several times.
Visual Studio seems to be happy with the in-memory pdb and refuses to update it, regardless of time-stamps or even size changes in the pdb.
The only way to reset this is to exit Visual Studio (the IDE) and restart it again.
In some rare occurrences, the IDE might be still running in the background (process explorer shows it there) and might hold the handle to the file open. You can kill the process before restarting the IDE.
Good Luck
I just encountered this error in VS2012. It is definitely caused by a bug in Visual Studio, which reveals itself in situations when the local PDB file of the main project has the same name as the final PDB file for the entire executable (even if the two are located in different directories!)
Consider this example.
Solution consists of three projects: main, a, and b. main is the top-level project for the executable, while a and b are libraries linked into main.
In all three projects $(IntDir) variable is set to $(SolutionDir)\$(Configuration)\$(ProjectName)\. This means that project main dumps its intermediate files to Debug\main\, project a - to Debug\a\ and so on.
In C/C++ -> Output Files settings all three projects have Program Database File Name value set to $(IntDir)$(TargetName).pdb. This means that project main generates its local PDB file as Debug\main\main.pdb, project b as Debug\b\b.pdb and so on.
Finally, in Linker -> Debugging settings of project main the Generate Program Database File value is set to $(OutDir)$(TargetName).pdb. This means that the global PDB file for the entire executable will be generated as Debug\main.pdb.
Note that in this setup each PDB file is generated in its own, separate directory.
In this setup you will get Debugging information cannot be found or does not match error if you attempt to run the program under the debugger. And if you take a look at the Debug\main.pdb file (which will exist), you will notice that it is exactly the same as Debug\main\main.pdb file! I.e. somehow the local PDB for main managed to overwrite what was supposed to be the global PDB for the final executable. I.e. the debugger is right to complain that the PDB file is "wrong". It is indeed wrong.
Again, in the above setup the final global PDB somehow gets overwritten by local PDB of the top project. I don't know why it happens. It appears to be a bug. (Note that even though these PDB files have the same name, they are generated in different directories, i.e. they should not conflict.)
A workaround that fixes this issue is to give the local PDB of project main a different name. For example, just go to C/C++ -> Output Files for the main project and change Program Database File Name value to $(IntDir)$(TargetName)_local.pdb (or to $(IntDir)12345.pdb if you so desire). This will eliminate the conflict and solve the problem.
Enable PDB creation by:
Right click on MyProject > Properties > Debugging:
C/C++ > General > Debug Information Output = Program Database (/Zi)
Linker > Debugging > Generate Debug Info = Yes (/DEBUG)
Clean MyProject, restart Visual Studio (just to be sure), rebuild MyProject.
The output folder should then contain *.pdb files.
If you debug optimized/release code consider switching off optimization via
C++ > Optimization > Optmization = Disabled (/Od)
I faced the same problem and tried all above mentioned solutions but it couldn't help me.
Then I found a new solution randomly and it worked.
Solution is that,in case you are having many projects in a solution then you should mark any one (specific one which you have to decide) project as a "Set as Startup Project".
Right click on that specific project and click "Set as Startup Project".
It worked for me.
The pdb or Program Database file appears to be missing (basically, the path has changed and can no longer be found by the compiler). See this related post for additional information.
I had a similar problem and the reason was that I had run one of the projects of my solution in a different process and that process couldn't be killed. I didn't think much of it. So when I was building the solution in a separate environment one of the pdb files didn't match so at the end I couldn't load any of the pdb files. I just restarted my computer and that fixed it.
Good luck
Restarting Visual Studio can fix one instance of this problem.
Right click on your project in the solution browser => Clean => Build.
That is if your build generates a .pdb at all (look in your target dir)
If not, you should enable debug by the steps mentioned in other posts
Most probably there are other reasons like .pdb / .exe file mismatch, something were not built / rebuilt, but I had similar case in Visual studio 2013 -
Something to do with virtual inline function - so I suspect.
In my case debugger were jumping in a middle of another C++ function, not the one which was called. Jump was off source code by 11 source code lines, but I cannot explain why much miscalculation happened. By simple rearranging functions I've got rid of this problem.
May be needs more detailed analysis why 11 lines shift happened originally.
Haven't seen this kind of behavior in any other visual studio.
This problem has bothered me for a long time. AnT's anwser is very helpful. The main idea is Don't have any two pdb files have the same name, even they are not in the same directory.
This is my situation: I have tow projects name "FooBar" and "FooBarDll", the first one is an exe, and the second one is a dll. I set both projects Target Name to be "FooBar", so that they will generate "FooBar.exe" and "FooBar.dll" respectively.
Then I set
"General -> Intermediate Directory" to be "$(OutDir)\$(ProjectName)\"
"C/C++ -> Output Files -> Program Database File Name" to be "$(IntDir)$(TargetName).pdb"
"Linker -> Debugging -> Generate Program Database File" to be "$(OutDir)$(TargetName).pdb"
So I get these files:
Debug\FooBar.exe
Debug\FooBar.pdb //C++ pdb
Debug\FooBar\FooBar.pdb //Linker pdb
Debug\FooBar.dll
Debug\FooBar.pdb // C++ pdb again!
Debug\FooBarDll\FooBar.pdb // Linker pdb
My solution is replacing every "TargetName" with "ProjectName", then I will get:
Debug\FooBar.exe
Debug\FooBar.pdb //C++ pdb
Debug\FooBar\FooBar.pdb //Linker pdb
Debug\FooBar.dll
Debug\FooBarDll.pdb // C++ pdb
Debug\FooBarDll\FooBarDll.pdb // Linker pdb
Then there is no conflict!
Give C/C++ pdb a suffix may be better, like: "C/C++ -> Output Files -> Program Database File Name" to be "$(IntDir)$(ProjectName)_C.pdb"
I had the same issue, and this link helped me solved the problem, by rename "symsrv.no" to "symsrv.yes" in VS IDE folder.
Curious, it happens to me that I needed to change the folder name from:
...\Custom Librarry (MyDll.dll(
to
...\Custom Librarry (MyDll.dll)
just by closing the parenthesis it worked !