0
votes

I am getting linker errors when trying to build (there are a bunch... here is one such):

error LNK2005: "public: int __cdecl std::ios_base::rdstate(void)const " (?rdstate@ios_base@std@@QEBAHXZ) already defined in msvcprt.lib(MSVCP90.dll)

I have a C project:

  • Configuration Type: Static Libary (.lib)
  • Use of MFC: Use Standard Windows Libraries
  • Use of ATL: Not Using ATL
  • Runtime Library: Multi-threaded DLL (/MD)

I have a C++ project:

  • Configuration Type: Dynamic Library (.dll)
  • Use of MFC: Use Standard Windows Libraries
  • Use of ATL: Dynamic Link to ATL
  • Runtime Library: Multi-threaded DLL (/MD)

I have a C++/CLI project that relies on the two projects above:

  • Configuration Type: Dynamic Library (.dll)
  • Use of MFC: Use Standard Windows Libraries
  • Use of ATL: Dynamic Link to ATL
  • Runtime Library: Multi-threaded DLL (/MD)
  • Common Language Runtime Support (/clr)
  • This links to the C project .lib
  • This has a project reference to the C++ DLL

These are built using the Visual 2010, but with the v3.5 toolset (so using 9.0).

Most solutions I've seen suggest that the Runtime library settings are not in sync. This is not the case here, they're all Multi-threaded DLL. They're all built in Release x64.

Does anything jump out with these project settings? Are there any more relevant settings I could share?

1
Surely the toolset is the problem here. With the linker error produced by both linking the VS2010 and the VS2008 version of msvcprt.lib. Check the C project and make sure it's vcxproj contains the required property.Hans Passant
It says "already defined in ..." does it say where else it is defined? Maybe in the rows before this message?selalerer
@HansPassant Under Configuration Properties > Generic > Platform Toolset, each project is set to v90. This is also reflected in the .vcxproj files: <PlatformToolset>v90</PlatformToolset>Jason X
Well, do try to eliminate that as the possible cause first. Does the link error disappear when you just let everything build with the default toolset? More diagnostics are available by using the linker's /VERBOSE command line option. That gives a trace of every .lib being linked.Hans Passant
Does the C or C++ project link to anything else? Any third party libraries?syplex

1 Answers

0
votes

I'd suggest to use the same setting everywhere and not mixing (static library and dll projects). If I remember well I ran into the same issue.