C++ Symbols not found - c++

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.

Related

VS2015 "no symbols loaded for this document" for .lib file

I have an issue where I have a .dll file that is compiled in debug. It statically links with a .lib file, which is also compiled in debug. The source is available for all of them. However when I run the .dll and attach VS to the process it can only step through the .dll's own function but not the ones in the .lib.
In the module view I can see that symbols are loaded for all the modules. How can ensure that .lib has symbols associated with it as well? As I understand because it is linked statically the symbols for it should be generated when compiling the "parent" .dll, is that correct? So is there something I need to do when building the .dll to make sure that ALL functions can be stepped through?
You need to add the location of the pdb file of the LIB you just built for the debugger to find the symbols in the appropriate Tools/Options section (usually the same directory as the output LIB).
Then, you can add the location of the source files in the according Solution Property page :
Then, Visual Studio debugger will find all appropriate information. It will load symbols and be able to jump into the LIB source code when appropriate.

What is .lib file contain while generating DLL

I am generating .dll in visual studio 2010. .lib, .dll, .pdb files are getting generated in output folder.
why .lib (is it static lib?) is genarating along with dll, what is the use of it and
what it contains actually ?
(In linux along with .so it can not have any other files, but why in Windows).
what is this .pdb files, what it contains and how will it be usefull ?
Thanaks in advance :)
.lib alongwith .dll is not static library. It tells the linker that the functions present in lib are to be loaded from the dll. By this, it creates dependency on the dll. Failing to find the dll will cause application to quit (which is checked at the time of start).
It is used in implicit linking of dll.
PDB file is used by debugger to find symbol information.
Why .lib (is it static lib?) is generating along with dll, what is the use of it and what it contains actually ?
No, that .lib is a import library and it is used in implicit linking.
What is this .pdb files, what it contains and how will it be useful ?
PDB file contains Symbol & line information and they are used by debugger to map hex/oct addresses to function names. PDB file is generated when your build your project.
without PDB your program stack trace would look like this
0x00002130
with PDB
0x00002130 yourprogram!function

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

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

How do I get CMake to create a dll and its matching lib file?

I'm using CMake to create a shared library via Visual Studio 2010. The solution outputs a dll file, but not a matching lib file. How do I tell CMake to generate the lib file so I can link other projects to the dll?
First of all check that you have at least one exported symbol in your shared library. Visual Studio does not generate the .lib file if dll does not exports symbols.
Next, check your cmake files - probably you have set CMAKE_ARCHIVE_OUTPUT_DIRECTORY variable or ARCHIVE_OUTPUT_DIRECTORY property of the shared library target. If these variable/property is set then Visual Studio will output .lib files into the different directory specified by that variable/property. (There also can be configuration-specific versions like ARCHIVE_OUTPUT_DIRECTORY_Release.)

Linking a DLL in Visual Studio

I'm using Visual Studio C++ 2005 on Windows XP.
I have created a DLL shared library using Visual Studio C++ 2005.
However, I am not sure how to link it. Normally I have just created the static libraries (*.lib).
Do I link the same way I would when linking a library. By using the properties C/C++ and linker general properties and selecting the path for the headers and library paths?
Many thanks for any advice.
When you create the DLL there should be a .lib file created for the purpose of dynamic linking. You can use these just as you would static .lib files.
This article explains Windows dlls well.
The .LIB file associated with a DLL
describes what (exported) symbols are
present in the DLL, together with
their locations.
To put it simply:
When you link: you Need Lib, not DLL
When you run it: you need dll, not lib (Put the DLL with your executable)