How can I force to load / create pdb files for a dll - c++

I have downloaded the latest version of SFML (a library) which includes source files, dlls, headers, and .lib files.
I have no problem using the library and it's linked dynamically.
I'd like to be able to step through the library code in the debugger (I used to be able to which earlier version), but now I can only see the assembly.
What is the usual way to generate pdb files to so?
thanks

Generally Visual Studio 2010 should automatically generate .pdb files for you (if you build in debug mode). Take a look in your Debug output folder. You can see where and what .pdb is being generated from your project settings;
Sterren

Related

Step into source code of linked library

I got some compiled C++ libraries (.lib, not compiled by myself) which I link in my own C++ project. I also got the source code.
Is it possible while debugging to step into functions from those libraries using the source code? How can I tell the Visual Studio debugger to use those source code files?
I guess that .lib files would need some kind of debugging information - can I find out if they got those?
Microsoft compilers store debugging information in separate .pdb files. When VS loads a library (say myLib ) used by an executable ( either by attaching to a running instance, or by starting it directly under debugger), it also searches for myLib.pdb. If it finds it, when you try to step in such a function, it will first ask you the location of the source corresponding to it. If it is correctly provided, you will be able to debug it.
Without .pdb files, I do not know any way to debug the external library at source code level.
Also, if there are no .pdb files, but you do have the source code for the external library, would it be possible for you to re-build it with debugging symbols (.pdb files ) ?

C++ Symbols not found

I'm trying to compile 3 projects:
A static library (.lib)
A dynamic library (.dll) that uses the .lib of the static library.
An application (.exe) that uses the .dll of the dynamic libaray
However, when trying to compile the .exe and setting a breakpoint, I get the warning "The breakpoint will not currently be hit. No symbols have been loaded for this document."
Well, I know that Visual Studio is missing the .pdb files somehow. However, I don't get why Visual Studio doesn't find it.
The .pdb file of the static library is being generated and is in the same folder than the .lib.
The dynamic library references the folder where the .lib and the .pdb of the static library are inside. A .pdb file is created in the same folder where the .dll is created for the dynamic libary.
The application copies the .dll and the .pdb of the dynamic library before compiling to the folder where the .exe is generated.
Still, Visual Studio is complaining that it doesn't have loaded any symbols. In the output console, it also tells me that it has loaded the symbols of the .exe and the .dll, but not of the .lib. Am I missing somewhat?
When you compile the .exe, you should still link to the .lib file that has been generated when compiling the .dll (so I am speaking about the .lib that comes with the dynamic library, not the one that comes with the static one).
Depending on your visual studio version you might configure that here:
Project->Properties->Configuration Properties->Linker>Input->Additional Dependencies
What version of Visual Studio? Are all the projects in the same solution? If so, Just add the library as a reference to the DLL, and the DLL as a reference to the EXE. Then Visual Studio handles linking everything up, and the .exe, .dll, and .pdb files should all be in the solution output directory.
Also, if you use LoadLibrary to load the DLL the debugger won't load the debug info and won't know where to set the breakpoints in the DLL until after it is loaded, which can cause the error you are seeing as well.

SFML library can't find .dll

I implemented the SFML library nightly build to my Visual Studio 2013, because the original one is not compatibile with this VS version. I done everything what is needed (added directory to include folder in both Debug and Release, added directory to .dll files), but it can't find the files in program. What else should be done to make this library work? Or should i consider changing Visual Studio to 2010?
You haven't given really to much information so I am just really guessing as to what the problem is.
added directory to .dll files
But that sounds like your problem right there. You don't add the directory that the .dll files are in to your project. The only directories you need to add to the project are the include directory and the library directory.
But anyways I am assuming you are using dynamic linking since otherwise you wouldn't be dealing with .dlls. Now different IDE's require that you place the .dlls in different spots but since you are dealing with VS2013 you need to copy whatever .dlls that you are using into the same folder where your program's compiled executable is (The .exe file).
Another option is to link statically instead of dynamically which I generally prefer to do on small projects but it is really up to the developer which he prefers.
When you link statically you don't need to include any .dlls. What you will need to do is recompile SFML's sources and make sure to build the library so it produces the static library files (They should be named something like sfml-graphics-s-d.lib for debug and sfml-graphics-s-d.lib for release).
Add that library directory which contains the static library files to your project and then link to them .lib files in VS's input window (Remember that -d is for the debug build).
Next you will need to add SFML_STATIC to your preprocessor options on both the release and debug build.
After that you are good to go and don't need to include the .dll files with your project. And again whether you choose to link dynamically or statically is really up to you and the project you are working on but for small projects I would suggest linking statically.

Why does Visual Studio generate these additional files?

In the output directory where Visual Studio places the compiled executable, there are three additional files of the types *.exp, *.lib, .pdb. I do not need those files and I would like to prevent the compiler from creating them.
This is how my build output directory looks like. I only need the *.exe file.
What are these additional files for? How can I disable that they are generated? If they are needed for the build process, is there a way to automatically remove them after the executable is created?
I am using Visual Studio 2012. If you need additional details, please comment.
EXP and LIB files But I don't want that .lib or .exp file for my COM library! . You could probably set the location of these files in the "Intermediate Output" setting and not have them in your release folder
I'm assuming you are looking to have only the dll and exe files in your final release directory and the *.exp, *.lib, .pdb files left in your intermediate directory as to not clutter the directory you are working in.
Visual Studio 2017
Open properties (Right click on the project in the solution explorer):
change settings as shown:
Import Library will define where the .lib and .exp files are created.
Generate Program Database File defines where the .pdb file is created.
Debug information format -- None will prevent pdb file from being created. Select this option for Release builds.
There some functions inside declared with as __declspec(dllexport).
It means that they are exported and linker thinks that there is a need to link with this dynamic library (no matter it is exe or dll - in general the structure is the same) and creates *.lib and *.exp file

Problem creating static/dynamic c++ libraries in visual studio

When I try to build my c++ library (in both static and dynamic mode) using visual studio 2008, in the debug folder, instead of .lib or .dll file, some .obj files are created along with an .idb and an .pdb file.
how can I make visual studio build the library file?
You're either looking in the wrong place or there's a problem in your build.
Open the BuildLog.htm file that VS creates when it does a build (there should be a link you can click in the Build Output window). It'll tell you where it's putting the file. Look for the line containing an "/OUT:" option.