linker issue moving a C++ project from vs2005 to vs2010 - c++

I am attempting to convert a project from Visual Studio 2005 to 2010. (To write a plugin for Maya 2014 as it is x64 only).
To start I am compiling with VS2010 against Maya 2013 x86. This compilation and linking works fine with VS 2005 but with 2010 I get a raft of errors along the lines:
error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,char const *,int)" (??3#YAXPAXPBDH#Z) referenced in function __unwindfunclet$?creator#exporter##SAPAXXZ$0
I have attached the command line that generates the output below (some parts omitted for clarities sake). You will note the VS toolset differs from 80 to 100 (2005 vs 2010) and the block { project libs compiled with VS2005 .sln file } is missing from 2010 linker. This block is the list of dependant projects compiled by Visual Studio as part of the solution build.
Do you know how I can get these locally built libs to show up in the 2010 linker? Should I even expect them too? And can anyone suggest other points of attack to resolve this?
2005 c/c++
/Od /I "C:\Program Files (x86)\Autodesk\Maya2013\include" /I {our engine include} /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "NT_PLUGIN" /D "REQUIRE_IOSTREAM" /D "_WINDLL" /FD /EHsc /MTd /Fp{pch file output} /Fo"Debug_2013\" /Fd"Debug_2013\vc80.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt
2010 c/c++
/I"C:\Program Files (x86)\Autodesk\Maya2013\include" /I{our engine include} /Zi /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "NT_PLUGIN" /D "REQUIRE_IOSTREAM" /D "_WINDLL" /Gm- /EHsc /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fp*{pch file output}* /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /TP
/analyze- /errorReport:prompt
2005 linker
/OUT:{dll output file} /NOLOGO /LIBPATH:"C:\Program Files (x86)\Autodesk\Maya2013\lib" /DLL /MANIFEST /MANIFESTFILE:{manifest output file} /NODEFAULTLIB:"libcmt.lib" /DEBUG /PDB:{pdb file} /MAP /IMPLIB:{import library} /ERRORREPORT:PROMPT Opengl32.lib pnglib_d.lib zlib_d.lib libeay32.lib ssleay32.lib Foundation.lib OpenMaya.lib OpenMayaUI.lib OpenMayaAnim.lib OpenMayaFX.lib OpenMayaRender.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 { project libs compiled with VS2005 .sln file }
/subsystem:windows /dll /incremental:yes /debug /export:initializePlugin /export:uninitializePlugin
2010 linker
/OUT:{dll output file} /NOLOGO /LIBPATH:"C:\Program Files (x86)\Autodesk\Maya2013\lib" /DLL "Opengl32.lib" "pnglib_d.lib" "zlib_d.lib" "libeay32.lib" "ssleay32.lib" "Foundation.lib" "OpenMaya.lib" "OpenMayaUI.lib" "OpenMayaAnim.lib" "OpenMayaFX.lib" "OpenMayaRender.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" /NODEFAULTLIB:"libcmt.lib" /MANIFEST /ManifestFile:{manifest output file} /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:{pdb output file} /MAP /PGD:{pgd output file} /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT
/subsystem:windows /dll /debug /export:initializePlugin /export:uninitializePlugin

Finally figured out the problem!!!!
Followed the "new way" Visual Studio 2010 has project dependancies listed. http://manski.net/2011/11/project-dependencies-in-visual-c/
This solved the "unresolved symbol" issues but created this error:
error MSB4006: There is a circular dependency in the target dependency graph
I solved this via the instructions here https://connect.microsoft.com/VisualStudio/feedback/details/534361/better-error-message-for-output-circular-dependency#details
Hope this saves someone a lot of trouble.

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

C++ DLL not loading debug symbols

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.

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

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