83

I am trying to use OpenCV in VS 2010. I am an amateur, and I am learning first steps from the OpenCV wiki. However, when trying to debug my project, I get the following errors:

'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file 'C:\Windows\SysWOW64\kernellbase.dll', Cannot find or open the PDB file

I have those files in the right directory, so why can't it open them? What should I do to fix the problem?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • What are you meaning with "in the right directory"? Is the PDB in the same folder as the DLL? – harper Jan 27 '11 at 08:49
  • 1
    @harper: Considering that the libraries in question are Windows system files, the PDBs are probably not *supposed* to be in the same folder as the DLL. The DLLs are in the C:\Windows\SysWOW64 directory, but the PDB symbols will likely be in your designed symbol cache directory. The one you specify in the Visual Studio debug options. – Cody Gray - on strike Jan 27 '11 at 08:52
  • @Cody Gray: Can you copy the PDBs to the directory (manually) or are you required to utilize the Microsoft (Source) Symbol Servers? – harper Jan 27 '11 at 08:59
  • @harper: I have no idea if it will work that way. I'm not sure if Visual Studio will find the PDB symbols there (although I imagine that it *would*). But, as far as licensing goes, I'm pretty sure that you have to use MS's symbol servers. How else are you going to obtain the PDB files? I'm also not sure why you'd want to boycott this. Visual Studio has all of this functionality built in, so why not take advantage of it? It's designed to cache the symbols locally, so you don't have to redownload them each time. I don't even notice it happening anymore. – Cody Gray - on strike Jan 27 '11 at 09:01
  • @Cody Gray: I dont' want to boycott anything. I even don't have these PDBs. But I am curious how it works. – harper Jan 27 '11 at 12:47
  • @harper: Sorry, I didn't mean for "boycott" to come across as condemnatory or anything. Have you read my answer below? I attempted to explain how symbol servers work there. It's just a public service provided by Microsoft so that users of Visual Studio can automatically download symbols for core operating system components as well as the .NET Framework. – Cody Gray - on strike Jan 27 '11 at 12:51

11 Answers11

123

First change the following parameters:

Tools -> Options -> Debugging -> Symbols -> Server -> Yes

Then press Ctrl+F5 and you will see amazing things.

01F0
  • 1,228
  • 2
  • 19
  • 32
seanlitow
  • 1,247
  • 1
  • 8
  • 2
20

I'm pretty sure those are warnings, not errors. Your project should still run just fine.

However, since you should always try to fix compiler warnings, let's see what we can discover. I'm not at all familiar with OpenCV, and you don't link to the wiki tutorial that you're following. But it looks to me like the problem is that you're running a 64-bit version of Windows (as evidenced by the "SysWOW64" folder in the path to the DLL files), but the OpenCV stuff that you're trying is built for a 32-bit platform. So you might need to rebuild the project using CMake, as explained here.

More specifically, the files that are listed are Windows system files. PDB files contain debugging information that Visual Studio uses to allow you to step into and debug compiled code. You don't actually need the PDB files for system libraries to be able to debug your own code. But if you want, you can download the symbols for the system libraries as well. Go to the "Debug" menu, click on "Options and Settings", and scroll down the listbox on the right until you see "Enable source server support". Make sure that option is checked. Then, in the treeview to the left, click on "Symbols", and make sure that the "Microsoft Symbol Servers" option is selected. Click OK to dismiss the dialog, and then try rebuilding.

Stuart Blackler
  • 3,732
  • 5
  • 35
  • 60
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • 7
    I'm not really sure what I'm supposed to say in response to that. Are you looking for more help? Or are you just leaving a comment? Because if you're looking for more help, you're going to have to explain what *exactly* went wrong when you "tried this" and what you mean by "didn't work". We're all programmers, you know that's not how a useful bug report is filed. – Cody Gray - on strike Jun 11 '12 at 20:07
  • Sorry for some reason my whole message didn't get pasted. But since then I've fixed it using the following method. http://stackoverflow.com/questions/1468726/breakpoint-will-not-currently-be-hit-why-not/10985066#10985066 – daveomcd Jun 11 '12 at 20:25
10

Visual Studio Community Edition 2015

Been having this error all day. I finally fixed it by going to Tools>Import and Export Settings> Reset all options > Reset General Settings.

Once it's reset go to Tools>Options>Debugging>Symbols> -- Then Check the box next to Microsoft Symbol Servers.

Run your app in debug mode, and it will open up windows saying it's downloading Symbols for a bunch of different .dll files. Let it finish doing this.

Once it completes, it should work again.

Nobody
  • 341
  • 2
  • 6
  • Upgrading to VS2109 16.8.1 somehow nuked the symbol cache, which from memory might have resided in the Users/Temp directory. The suggested general reset may not be necessary before re-acquiring the symbols. Ensure the symbols have a safe cache directory- and wait an hour or so for them (~375mb) to load. I chose MS over Nuget server only from force of habit. Instead of the reset, the cure for paranoia was to remove all the VS generated files (except .git) for the project before beginning afresh. – Laurie Stearn Nov 13 '20 at 13:23
3

I had the same problem. It turns out that, compiling a project I got from someone else, I haven't set the correct StartUp project (right click on the desired startup project in the solution explorer and pick "set as StartUp Project"). Maybe this will help, cheers.

1

Referring to the first thread / another possibility VS cant open or find pdb file of the process is when you have your executable running in the background. I was working with mpiexec and ran into this issue. Always check your task manager and kill any exec process that your gonna build in your project. Once I did that, it debugged or built fine.

Also, if you try to continue with the warning , the breakpoints would not be hit and it would not have the current executable

Mpi
  • 11
  • 1
1

For VS2013 users who find themselves here as I did:

Tools -> Options -> Debugging -> Symbols

You'll see that the Cache symbols in this directory: field is empty; you can either browse/enter the path yourself or just go ahead and click the Load all symbols button. An alert window will appear saying "Since you haven't selected a symbol-cache directory the default will be used". You'll now see C:\Users\XXXX\AppData\Local\Temp\SymbolCache in the previously empty path-field. Click Load all symbols a second time and you should be set. Hit ok, and just for the sake of diligence, clean and rebuild your solution.

ahall
  • 129
  • 2
  • 7
0

I'm having the same warnings. I'm not sure it's a matter of 32 vs 64 bits. Just loaded the new symbols and some problems were solved, but the ones regarding OpenCV still persist. This is an extract of the output with solved vs unsolved issue:

'OpenCV_helloworld.exe': Loaded 'C:\OpenCV2.2\bin\opencv_imgproc220d.dll', Cannot find or open the PDB file

'OpenCV_helloworld.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Symbols loaded (source information stripped).

The code is exiting 0 in case someone will ask.

The program '[4424] OpenCV_helloworld.exe: Native' has exited with code 0 (0x0).

sparaflAsh
  • 646
  • 1
  • 9
  • 26
0

I had the same problem. Debugging does not work with the stuff that comes with the OpenCV executable. you have to build your own binarys.
Then enable Microsoft Symbol Servers in Debug->options and settings->debug->symbols

john k
  • 6,268
  • 4
  • 55
  • 59
0

I ran into the same issue. When I ran my Unit Test on C++ code, I got an error that said "Cannot find or open the PDB file".

Logs

When I looked at the Output log in Visual Studio, I saw that it was looking in the wrong folder. I had renamed the WinUnit folder, but something in the WinUnit code was looking for the PDB file using the old folder name. I guess they hard-coded it.

Found the Problem

When I first downloaded and unzipped the WinUnit files, the main folder was called "WinUnit-1.2.0909.1". After I unzipped the file, I renamed the folder to "WinUnit" since it's easier to type during Visual Studio project setup. But apparently this broke the ability to find the PDB file, even though I setup everything according to the WinUnit documentation.

My Fix

I changed the folder name back to the original, and it works.

Weird.

0

Had the same problem here but a different solution worked.

First, I tried the following, none of which worked:

  1. Load symbols as suggested by seanlitow

  2. Remove/Add reference to PresentationFramework and PresentationCore

  3. Restart system

The solution was to undo the last few changes I had made to my code. I had just added a couple radio buttons and event handlers for checked and unchecked events. After removing my recent changes everything compiled. I then added my exact changes back and everything compiled properly. I don't understand why this worked - only thing I can think of is a problem with my VS Solution. Anyway, if none of the other suggestions work, you might try reverting back your most recent changes. NOTE: if you close & re-open Visual Studio your undo history is lost.. so you might try this before you close VS.

Thomas Bailey
  • 191
  • 2
  • 6
0

I've found that these errors sometimes are from lack of permissions when compiling a project - so I run as administrator to get it to work properly.