cédric
cédric

Reputation: 121

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

Upvotes: 0

Views: 130

Answers (1)

James McNellis
James McNellis

Reputation: 355099

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.

Upvotes: 1

Related Questions