Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unresolved symbols after converting VS2012 Windows 8 Metro solution to VS2013 (on Windows 8.1)

I have a question, which I'm currently unable to tackle effectively since I'm still unfamiliar with Metro app development. So please bear with me :)

Long story short, I have a large, complex VS2012 Metro app managed+native solution (currently built on Windows 8) into VS2013 targeting Windows 8.1.

I imported the solution into VS2013 (hosted on Windows 8.1), and run the conversion for it and all the sub projects therein. Stuff compile, but it is with the linker that we run into problems. This is an example of the linker errors we get:

    error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___mbsrchr referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol _getenv referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___endthreadex referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___mbsrchr referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___mbsnbicmp referenced in function <blahblahblah>
    error LNK2019: unresolved external symbol __imp___dupenv_s referenced in function <blahblahblah>

The thing is that for every single symbol that is 'missing', we can see the that the declaration is present in the MS Windows header files supplied with VS2013. Inspecting the references in each sub-project shows that they are referencing the Windows 'core' libs.

Any ideas why this is happening? Thanks.

like image 423
luis.espinal Avatar asked Dec 10 '13 20:12

luis.espinal


1 Answers

we can see the that the declaration is present in the MS Windows header files supplied with VS2013. Inspecting the references in each sub-project shows that they are referencing the Windows 'core' libs

It is going to be difficult to diagnose what went wrong with this little information, but it is pretty clear that you are looking in the completely wrong corner for this problem. The missing symbols are not Windows api functions, they are C runtime support functions. They are only used in a C++ project, you've been looking at .NET projects.

So you'll need to focus on the one project that generates these linker errors, it is a C++ project. The linker command that's issued to get it to link to the .lib that has these symbols is completely automagic so there isn't much that can go wrong. The very first thing to do is to force a complete rebuild so it won't use outdated .obj and .lib files that were left over from a previous build in VS2012. Right-click the project and choose Rebuild.

And it is worth taking a look at the .vcxproj file for this project with a text editor (like Notepad) and ensure that the conversion went properly and made the correct changes:

  • the ToolsVersion property must be changed from "4.0" to "12.0"
  • the MinimumVisualStudioVersion property must be changed from 11.0 to 12.0
  • two new properties are added, ApplicationType (Windows Store) and ApplicationTypeRevision (8.1)
  • every configuration's PlatformToolset property must be changed from v110 to v120

There is a log file in the Debug\projectname.tlog directory named link.read.1.tlog that contains diagnostics, it shows all the .lib files that the linker uses. It must contain this line:

C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\VC\LIB\STORE\VCCORLIBD.LIB

Which is the .lib file that contains these symbols.

like image 87
Hans Passant Avatar answered Oct 15 '22 21:10

Hans Passant