LNK 2038 error after upgrading to visual studio 2015 - c++

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).

Related

install cURLpp errors c++

I recently installed cURLpp from NUGET in visual studio. Everything installed correctly and when I try to use cURLpp I get the following error:
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol __imp__curl_easy_setopt referenced in function "public: void __thiscall curlpp::internal::CurlHandle::option<void *>(enum CURLoption,void *)" (??$option#PAX#CurlHandle#internal#curlpp##QAEXW4CURLoption##PAX#Z) Project1 C:\Users\Joel\documents\visual studio 2015\Projects\Project1\Project1\main.obj 1
This error stops happening when I remove #include Options.hpp
IDE: Visual Studio 2015, Compiling on Windows 10

Unresolved external symbols in Visual Studio 2013 when using UHD

I can't seem to get a very simple program to compile in Visual Studio 2013. My goal is to incorporate UHD into a C++ program (UHD Driver and Libraries for Windows). I downloaded and installed the Windows UHD package.Since the library also depends on Boost, I also downloaded the appropriate Boost library. After that, I wrote a quick test program in Visual Studio 2013:
#include "stdafx.h"
#include <iostream>
#include <uhd\usrp\multi_usrp.hpp>
#include <uhd\types\device_addr.hpp>
using namespace uhd;
int main(void)
{
device_addr_t hint;
device_addrs_t dev_addrs = device::find(hint);
system("pause");
return 0;
}
In case anyone is interested, this program should locate any USRPs attached to a host PC. I defined the appropriate include paths in Visual Studio: . .
To be clear, I included two paths to the header files:
C:\Program Files (x86)\UHD\include and C:\Program Files (x86)\boost_1_55_0
and one path to the library:
C:\Program Files (x86)\UHD\lib
When I wrote the above program, Visual Studio recognized the additional include files, recognized device_addr_t as a typedef, and didn't throw any errors. However, when I built the program, I received these errors:
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::vector<class uhd::device_addr_t,class std::allocator<class uhd::device_addr_t> > __cdecl uhd::device::find(class uhd::device_addr_t const &)" (__imp_?find#device#uhd##SA?AV?$vector#Vdevice_addr_t#uhd##V?$allocator#Vdevice_addr_t#uhd###std###std##ABVdevice_addr_t#2##Z) referenced in function _main C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::~device_addr_t(void)" (__imp_??1device_addr_t#uhd##QAE#XZ) referenced in function "public: void * __thiscall uhd::device_addr_t::`scalar deleting destructor'(unsigned int)" (??_Gdevice_addr_t#uhd##QAEPAXI#Z) C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall uhd::device_addr_t::device_addr_t(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0device_addr_t#uhd##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function _main C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\uhd_test\uhd_test.obj uhd_test
Error 4 error LNK1120: 3 unresolved externals C:\Users\...\Documents\Visual Studio 2013\Projects\uhd_test\Debug\uhd_test.exe uhd_test
I've encountered these errors before in other programs, but I was able to resolve them relatively easily; either I would misspell a crucial include, or there would be an issue with a template class. However, in this instance, I can't seem to resolve the issue.
Any constructive input would be appreciated.
NOTE: In addition to defining the library directory path, I've explicitly added the UHD library, and I receive the same errors.
I got your example working. Here's the software versions I used since you didn't mention much in your description:
Microsoft Visual Studio 2013
VC++ Redistributable Package for VS2013 (vcredist_x86)
UHD 003.007.002, VS2013, Win32
Boost 1.56, lib32-msvc-12.0 binary package
Here are the project configuration properties you need to set in your VS2013 applications:
C/C++ -> General -> Additional Include Directories
C:\local\boost_1_56_0
C:\Program Files (x86)\uhd\include
Linker -> General -> Additional Library Directories
C:\local\boost_1_56_0\lib32-msvc-12.0
C:\Program Files (x86)\uhd\lib
Linker -> Input -> Additional Dependencies
uhd.lib
I think the last step is what's tripping you up, good luck!
I followed exactly what David Greene said, and I ended up with the same errors. Eventually I figured out that I had downloaded the 64-bit UHD, but I was using Visual Studio 2013 Express, which was a 32-bit compiler. Downloading the 32-bit version of UHD for Visual Studio 2013 solved the problem. For anyone else having this problem, double check that the compiler matches which version of UHD you install.

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.

Issue moving project to Visual Studio 2012

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.