Issue moving project to Visual Studio 2012 - c++

I've just moved over to Visual Studio 2012 RC to give it a test run. But I'm having problems with getting my DirectX 11 game project to work with it. When I build I get 1152 warnings that all look like this:
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\dwrite.h(4972): warning C4005: 'DWRITE_E_NOFONT' : macro redefinition
1> c:\program files (x86)\windows kits\8.0\include\shared\winerror.h(50217) : see previous definition of 'DWRITE_E_NOFONT'
They come from all the DirectX headers and each one is for a different macro. I also get some unresolved external symbols I didn't get before:
1>base.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z) referenced in function __unwindfunclet$??__EgGame##YAXXZ$0
1>game.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z)
1>world.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z)
The only place I would think delete would be overloaded is in #include <crtdbg.h>, which I am using in my project. But the thing is, all this working in Visual Studio 2010.
Not to sure what the problem is. Am I missing any steps when converting the projects?
I should also mention that my computer previously crashed (I only lost Windows, and the registry) so I've had to reinstall most of my programs. I don't know if this will come into play, but I haven't compiled the project on VS2010 since the crash.

You need to recompile all your libraries with VS2012 in order to fix this issue. It is a problem with the new C run-time library included with the VS2012.

Related

Link errors when trying to compile against an old STD library and windows SDK

I have an old project that is compiled in VS2005 (Sadly). It has to remain in VS2005 so it can link properly to another process which has the VS2005 CRT,MFC, etc.
Now I need to compile this project in VS2015, using the old VS2005 toolset.
I've changed the project's VC++ directories to the old folders for all the STD and Windows SDK headers/libs (Include directories, Reference Directories, Library Directories, Source Directories).
This trick used to work fine while working with VS2010, but on VS2015 I'm getting some weird link errors:
1>Project1.obj : error LNK2019: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M#YGXPAXIIP6EX0#Z#Z) referenced in function "public: virtual void * __thiscall PluginInterface::`vector deleting destructor'(unsigned int)" (??_EPluginInterface##UAEPAXI#Z)
1> 1>
1>StdAfx.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M#YGXPAXIIP6EX0#Z#Z)
1> 1>
1>Project1.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3#YAXPAXI#Z) referenced in function __unwindfunclet$?getInstance#Project1##SAPAV1#XZ$0
1> 1>
1>Project1.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete[](void *,unsigned int)" (??_V#YAXPAXI#Z) referenced in function "public: virtual void * __thiscall PluginInterface::`vector deleting destructor'(unsigned int)" (??_EPluginInterface##UAEPAXI#Z)
Why is it looking for this inner implementation of the deleter ? Should it be getting the implementation from the headers? Why would it work in VS2010 and not VS2015?
How can I fix this properly ?
So, after reading a lot of breaking changes documentations i found a flag that can suppress these new c++14 delete implementations here, under Placement new and delete.
Adding the flag /Zc:sizedDealloc- removes the missing operator delete() implementations.
Project properties -> Configuration Properties -> C/C++ -> Command Line -> /Zc:sizedDealloc-
you can revert to the old behavior by using the compiler option
/Zc:sizedDealloc-. If you use this option, the two-argument delete
functions don’t exist and won't cause a conflict with your placement
delete operator.
For the eh vector destructor iterator error I've opened a separate question, and answered it there.

LNK 2038 error after upgrading to visual studio 2015

i was working on a project in visual studio 2013 , then i upgraded to visual studio 2015 . the project was ok on earlier version but now i get these errors :
1>sfml-system-s-d.lib(String.cpp.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1800' doesn't match value '1900' in Aircraft.obj
1>sfml-graphics-s-d.lib(VertexArray.cpp.obj) : warning LNK4049: locally defined symbol ??0_Container_base12#std##QAE#XZ (public: __thiscall std::_Container_base12::_Container_base12(void)) imported
1>sfml-system-s-d.lib(String.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::bad_cast::bad_cast(char const *)" (__imp_??0bad_cast#std##QAE#PBD#Z) referenced in function "class std::ctype<wchar_t> const & __cdecl std::use_facet<class std::ctype<wchar_t> >(class std::locale const &)" (??$use_facet#V?$ctype#_W#std###std##YAABV?$ctype#_W#0#ABVlocale#0##Z)
1>sfml-graphics-s-d.lib(Shader.cpp.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::bad_cast::bad_cast(char const *)" (__imp_??0bad_cast#std##QAE#PBD#Z)
there are too many of them , but i just included one of each .
i found similar questions , but none of them worked for me . i am using SFML library .
steps i've done to solve the problem are :
downloading sfml for vc14 .
rebuild sloution .
try to ignore _MSC_VER in preprocessor commands(there were no 2038 errors any more , but still i had other link errors) .
no success ...
There is a mismatch among version of Visual Studio used for libraries and project which you are try to compile. Some of them are compiled with Visual Studio 2013 while you're building the project with Visual Studio 2015.
If you want to use Visual Studio 2015 to compile your project, you must compile all the required libraries (e.g. SFML) with Visual Studio 2015 (or, in alternative, find pre-built libraries with VS2015 if available).

Boost compile error with VS 2008 but not 2010 or 2012

I am wondering if it is possible to compile the boost chat client example found here (the example with the 3 files: chat_message.hpp, chat_client.cpp, and chat_server.cpp):
http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/examples.html
with VS 2008 compiler? It compiles with 2012, but not 2008 or 2010. I am using boost version 1_51
I'm compiling it from within VS 2012 but using the platform toolset for VS 2008. When i change the compiler to 2008, all of a sudden the namespace line (in chat_client.cpp) gets underlined in red by intellisense:
using boost::asio::ip::tcp;
I haven't been able to figure out what it is that is causing the 2008 compiler to fail and if there is some way to get around this (perhaps using an older version of boost?).
This is the output I get when I compile with 2008 (with #define BOOST_LIB_DIAGNOSTIC):
1> Linking to lib file: libboost_system-vc90-mt-1_51.lib
1> Linking to lib file: libboost_date_time-vc90-mt-1_51.lib
1> Linking to lib file: libboost_regex-vc90-mt-1_51.lib
1> Linking to lib file: libboost_thread-vc90-mt-1_51.lib
1> Linking to lib file: libboost_chrono-vc90-mt-1_51.lib
1>c:\users\dustin\documents\boostexamples\boostchatclientexample\chat_message.hpp(70): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\string.h(144) : see declaration of 'strncat'
1>c:\users\dustin\documents\boostexamples\boostchatclientexample\chat_message.hpp(84): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(366) : see declaration of 'sprintf'
1>chat_client.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAABVerror_category#12#XZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAABVerror_category#12#XZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach#thread#boost##QAEXXZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join#thread#boost##QAEXXZ)
1>chat_client.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread#thread#boost##AAEXXZ)
1>C:\Users\dustin\Documents\BoostExamples\BoostChatClientExample\Release\BoostChatClientExample.exe : fatal error LNK1120: 5 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Including a visual 2005 library in a visual C 2010 project

I have a c++ qt5 project under Microsoft visual studio professionnal 2010. I have to include a library .lib in my project that is compiled with Microsoft Visual 2005 and depends of the visual 2005 vorsion of the STL. As a consequence when I try to compile my project I got the following link error (here are the three first errors among more):
libmegamatching.lib(BImage.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (__imp_?sputn#?$basic_streambuf#DU?$char_traits#D#std###std##QAEHPBDH#Z)
libmegamatching.lib(makeCanonicalImage.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (__imp_?sputn#?$basic_streambuf#DU?$char_traits#D#std###std##QAEHPBDH#Z)
M_Control.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (__imp_?sputn#?$basic_streambuf#DU?$char_traits#D#std###std##QAEHPBDH#Z)
My collegue solved this problem encapsulating the library into a microsoft managed C++ library…but I didn't try that yet because I am not excited about adding a .NET dependencie to my project.
Is there other solutions? Of cours I cannot recompile the library with visual 2010 nor change my visual version.
I was thinking about making a visual 2005 std library .lib…but I don't know if there is a way to do that?
Thanks in advance
You either need to [a] recompile the library using Visual C++ 2010 or [b] encapsulate the library within its own module (DLL) and provide a flat C interface over it.
Within a single module, you cannot mix objects built with different major versions of the Visual C++ libraries.

fftw in Visual Studio?

I'm trying to link my project with fftw and so far, I've gotten it to compile, but not link. As the site said, I generated all the .lib files (even though I'm only using double precision), and copied them to C:\Program Files\Microsoft Visual Studio 9.0\VC\lib, the .h file to C:\Program Files\Microsoft Visual Studio 9.0\VC\include and the .dll to C:\windows\system32.
I've copied the tutorial program, and the exact error I am getting is:
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_free referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_destroy_plan referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_execute referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_plan_dft_1d referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_malloc referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
So, what could be wrong with my project setup? Thanks!
My case
Using FFTW in Visual Studio 2010
Precompiled FFTW 3.3.1 Windows DLLs install using fftw-3.2.1-dll.zip, on my Windows XP machine.
Open cmd window and go to lib.exe folder C:\Program Files\Microsoft Visual Studio 10.0\VC\bin>
Type lib /def:libfftw3-3.def
Type lib /def:libfftw3f-3.def
Type lib /def:libfftw3l-3.def
If you have a error on command, copy any mspdb80.dll or mspdb100.dll file to in bin directory.
You will get 6 files
libfftw3-3.exp, libfftw3-3.lib, libfftw3f-3.exp, libfftw3f-3.lib,
libfftw3l-3.exp and libfftw3l-3.lib
and copy it to programming directory.
Delete all mspdb80.dll or mspdb100.dll file from bin directory.
Closed Project and open again and rebuild it again.
Have you actually linked against the library in the project you're building?
Project -> Properties -> Linker -> Input -> Additional dependencies
You need to add the library's filename to that field.
Assuming you've actually linked your project against the lib and it doesn't work, use /verbose:lib and paste the output of that and the output of
dumpbin /exports fftw.lib | findstr fftw_free
I had similar problem. What helped was compiling the fftw libs with this help Compiling FFTW source in Visual studio. Actually more closely the problem was compiling my application Win 32 and trying to use x64 -libraries. So make sure the platform is same.