C++ DLL not loading debug symbols - c++

In my solution I have two projects: one is a C++ DLL, and the other is a C# Windows Forms EXE (with the latter having a build dependency on the former). The DLL gets linked in correctly and works (my test function returns the right number, at least). The actually useful functionality is throwing an exception somewhere, but I can't debug it because none of the debug symbols for the C++ project are being loaded.
The PDB is definitely being generated! The EXE, DLL and PDB are all in the same folder. I even added their directory as one of the symbol file locations (Options > Debugging > Symbols), but this didn't do anything.
Apparently, the Modules window is supposed to tell you something, but my DLL doesn't appear there (yet it still works fine).
I'm using a x64 DLL with no compiled headers, if that makes any difference.
Compiler commandline:
/GS /W3 /Zc:wchar_t /I"E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\MusicStreamingClient\RapidJson\include\" /ZI /Gm /Od /Fd"x64\Debug\vc140.pdb" /Zc:inline /fp:precise /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MUSICSTREAMINGCLIENT_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /MDd /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\MusicStreamingClient.pch"
Linker commandline:
/OUT:"E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\x64\Debug\MusicStreamingClient.dll" /MANIFEST /NXCOMPAT /PDB:"E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\x64\Debug\MusicStreamingClient.pdb" /DYNAMICBASE "E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\MusicStreamingClient\RapidJson\x64\Debug\RapidJson.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\x64\Debug\MusicStreamingClient.lib" /DLL /MACHINE:X64 /INCREMENTAL /PGD:"E:\Users\Sean\Documents\Visual Studio 2015\Projects\MusicStreamingClient\x64\Debug\MusicStreamingClient.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\MusicStreamingClient.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
Any help would be appreciated.

You are currently debugging Managed code only. Native symbols will not be visible. You need to change your debug option to enable both Managed and Native modes for your project.

Related

Why visual studio compiler embeds variable names as strings in the compiled EXE?

I am compiling some program i wrote, and when i run strings.exe (from sysinternals, a tool which displays the strings in a binary file) i see variable names from my code.
I am using visual studio C++ compiler, i already tried to disable debug info generation and playing with the project properties but nothing helped so far.
Has anyone encountered this problem before?
Thanks.
EDIT:
as requested, the compilations command lines.
compiler:
/permissive- /Yu"pch.h" /GS- /analyze- /W3 /Zc:wchar_t /Zi /Gm- /Od /sdl /Fd"Debug\vc141.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /GF- /WX- /Zc:forScope /RTCs /GR- /Gd /Oy- /MTd /FC /Fa"Debug\" /nologo /Fo"Debug\" /Fp"Debug\a.pch" /diagnostics:classic
linker:
/OUT:"C:\a.exe" /MANIFEST /NXCOMPAT:NO /FUNCTIONPADMIN /PDB:"C:\a.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /FIXED:NO /DEBUG /MACHINE:X86 /INCREMENTAL:NO /PGD:"C:\a.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\a.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

VS 2013 release DLL linking to debug version

I have the following (example) code of which I require to compile a release version.
// library.cpp : Defines the exported functions for the DLL application.
//
#include <stdio.h>
extern "C"
{
__declspec(dllexport) void DisplayHelloFromDLL( int value)
{
printf("Hello from DLL : data=%d\n", value);
}
}
The code compiles and links with one problem that it refers to the debug version of the
runtime library no matter what I try.
Platform Visual Studio 2013 update 5
Issues - Links to MSVCR120d.dll as opposed to MSVCR120.dll
Configuration Release - Win32 Dll
Manifest Present
Compiler CLI
/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /Fd"Release\vc120.pdb" /fp:precise /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBRARY_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\library.pch"
Note: /MD is correct i.e. no static, no debug, dll
Linker CLI
/OUT:"C:_progdbg\Call_DLL\Caller\Release\library.dll" /MANIFEST /LTCG /NXCOMPAT /PDB:"C:_progdbg\Call_DLL\Caller\Release\library.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"C:_progdbg\Call_DLL\Caller\Release\library.lib" /DLL /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"C:_progdbg\Call_DLL\Caller\Release\library.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release \library.dll.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
Dependency Walker shows that library is dependent on MSVCR120d.dll
Could someone please tell me which setting is wrong.
Many Thanks

Is it possible to statically link libcurl, libeay32 and ssleay32?

I'm using Visual Studio 2013 and I want to use libcurl statically (without any external dlls).
I've statically linked libcurl that I've compiled with the following command:
nmake /f Makefile.vc mode=static WITH_SSL=static WITH_DEVEL=C:\OpenSSL-Win32 VC=12 ENABLE_SSPI=no ENABLE_IDN=no ENABLE_WINSSL=no DEBUG=no MACHINE=x86 GEN_PDB=no ENABLE_IPV6=yes
I have downloaded OpenSSL and linked the following libs to my project:
C:\OpenSSL-Win32\lib\VC\static\zlibeay32MD.lib
C:\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib
Everything seems to be fine, and I can successfully compile my project.
But when I run the program, I'm receiving the following error:
If I put libeay32.dll and ssleay32.dll to the same folder of program it works without problem.
I don't understand why it requires these dlls, I've used WITH_SSL=static option to compile libcurl and should load from static library, right?
Update:
C/C++ -> Command Line:
/Yu"stdafx.h" /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /I"C:\VisualCpp\Libraries\curl-7.42.1\builds\libcurl-vc12-x86-release-static-ssl-static-ipv6\include\curl" /I"C:\OpenSSL-Win32\\include\openssl" /Zi /Gm- /O2 /sdl /Fd"Release\vc120.pdb" /fp:precise /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CURL_STATICLIB" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\Launcher.pch"
Linker -> Command Line:
/OUT:"C:\VisualCpp\Launcher\Release\Launcher.exe" /MANIFEST /LTCG /NXCOMPAT /PDB:"C:\VisualCpp\Launcher\Release\Launcher.pdb" /DYNAMICBASE "libcurl_a.lib" "libeay32MD.lib" "ssleay32MD.lib" "ws2_32.lib" "wldap32.lib" "advapi32.lib" "kernel32.lib" "comdlg32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MACHINE:X86 /NODEFAULTLIB:"libcmt.lib" /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"C:\VisualCpp\Launcher\Release\Launcher.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\Launcher.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

Visual C++, breakpoints do not break

I have a project in Visual C++ 2010 (Win32 application, non-managed code) in which I'm experiencing a really strange behavior. I put a breakpoint and it simply does not break!
The clues:
A PDB file is generated in the exe file path.
The Debug/Modules window shows the message "Binary was not built with debug information.".
Loading the PDB file manually (Debug/Modules, right click on the executable module, Load Symbols From/Symbols Path then double click on the PDB file) says "A matching symbol file was not found on this folder.".
My settings:
C++/General/Debug Information Format: Program Database.
C++/Optimization: Disabled.
C++/Code generation/Runtime library: Multi-threaded Debug.
Linker/Debugging/Generate Debug Info: Yes.
Linker/Debugging/Generate program database: $(TargetDir)$(TargetName).pdb.
Compiler command line:
/I"..\..\calibur64k\include" /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /Zi /nologo /W3 /WX- /Od /Oy- /D "D3D_DEBUG_INFO" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug\calibur_app.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /Zl /errorReport:queue
Linker command line:
/OUT:"C:\Users\David\Desktop\calibur64k\vs2010\Debug\calibur_app.exe" /INCREMENTAL:NO /NOLOGO "kernel32.lib" "user32.lib" "d3dcompiler.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "C:\Users\David\Desktop\calibur64k\vs2010\Debug\calibur64k.lib" /MANIFEST /ManifestFile:"Debug\calibur_app.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\David\Desktop\calibur64k\vs2010\Debug\calibur_app.pdb" /ASSEMBLYDEBUG /SUBSYSTEM:WINDOWS /PGD:"C:\Users\David\Desktop\calibur64k\vs2010\Debug\calibur_app.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
Nothing I've found on the Internet helped me :( Any ideas guys? Thanks!
The problem has been solved by trial and error :)
For anyone could be interested in:
Linker/Manifest File/Generate Manifest: set it to No.
Linker/Manifest File/Allow Isolation: set it to No.
Linker/Embedded IDL/Ignore embedded IDL: set it to Yes.
That's it. Maybe the generated PDB file manifest or the executable manifest were wrongly setup for a C++ project?
Thanks for your answers.
My Settings of Visual c++ 2010:
Linker/Manifest File/Generate Manifest: Yes.
Linker/Manifest File/Allow Isolation: Yes.
Linker/Embedded IDL/Ignore embedded IDL: No.
I have used these settings in all of my programs and break points are successfully hit.
So, my inference is that what you have proposed might not be the right solution.

Dll compiled under Windows 7 doesn't work in Windows XP

I'm building an addon for NodeJS.
Works just right in Windows 7. But in Windows XP it won't load, doesn't open it no matter what I do. ERROR: Unable to load shared library c:\tst\tst.node
I'm compiling the DLL from VS2010 with the following options:
c/c++ opts
/I"c:\tst\nodemodule\cvv8\include" /I"c:\tst\nodemodule\node-src\deps\uv\include" /I"c:\tst\nodemodule\node-src\deps\v8\include" /I"c:\tst\nodemodule\node-src\src" /I"c:\tst\nodemodule\node-src\deps\zlib" /I"c:\tst\nodemodule\node-src\deps\http_parser" /I"c:\tst\nodemodule\cvv8\include\cvv8" /Zi /nologo /W0 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "TST_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\tst.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue
linker opts
/OUT:"c:\tst\tst.node" /INCREMENTAL:NO /NOLOGO /DLL "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST:NO /ManifestFile:"Release\tst.node.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:"c:\tst\tst.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"c:\tst\tst.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
What's wrong? Is this UTF-8 related?
The best tool to diagnose such problems is the dependency walker.
Open your dll in dw and you'll immediately see why it won't load: most likely there are some dlls/libs missing your dll depends upon.
Before including windows headers (usually in stdafx.h), try setting the windows version macros to ensure you're not using api's that are only available after XP.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx#setting_winver_or__win32_winnt