2012-05-20 This is an update to the original post of 2012/05/09 that was partially correct.
The Problem
When linking with VS11 Beta, you receive a TRACKER
error of TRK0005
or TRK0002
referencing either rc.exe
or mt.exe
. This means that VS11 Beta cannot find the tools needed for manifest generation.
What Works
Fixes that Work |
---|
Explicitly add path to WinSDK x86 bin directory to VC++ Directories/Executable Directories for every project under Property Pages |
Add WinSDK x86 bin directory to system PATH |
Disable manifest generation. |
What Doesn't Work
Things that don't work but should |
---|
Adding WinSDK x86 bin path to VC++ Directories/Executable Directories in Microsoft.Cpp.Win32.user and Microsoft.Cpp.x64.user Property Pages |
Adding a custom Property Page to the project that contains the WinSDK x86 bin to the Project |
Reset settings in Visual Studio 11 Beta |
Background
I've just started using Visual Studio 11 Beta. One of the nice additions to VS11 is that it incorporates the idea of multiple platform toolsets - that is, compilers. On the Property Pages for a project under Configuration Properties/Platform Toolset is a drop-down list of the registered compilers.
Linking Fails due to Problems with Manifest Generation
Compilation works fine with Visual Studio 2010. (I haven't tested the others.) When I switched to the Visual Studio 11 compiler, I get the error:
TRACKER : error TRK0005: Failed to locate: "rc.exe". The system cannot find the file specified.
Sometimes I get the error
TRACKER : error TRK0002: Failed to locate: "rc.exe". The system cannot find the file specified.
Playing around trying to fix the problem I sometimes got the same errors except with mt.exe instead of rc.exe.
Searching on Google didn't turn up much useful; StackOverflow.com did point me in the right direction: mt.exe
and rc.exe
come with Windows SDK and are part of the packaging and manifest generation that Visual Studio does by default.
Manifest?
OK, I know the manifest is important for .NET assemblies. Does it matter for native code? According to Building C/C++ Isolated Applications and Side-by-Side Assemblies, the manifest helps ensure that the distributed application is running with the right DLLs; in other words, it addresses DLL Hell as described in the (somewhat poorly named) Simplifying Deployment and Solving DLL Hell with the .NET Framework.
How to Fix
There are at least three ways to address the problem:
- Specify a per-project directory list for Executables Directories.
- Add the appropriate WinSDK path to the system PATH environment variable.
- Disable manifest generation.
Specify a per-project directory list
Pros
- Quickest fix for one or a few projects
- Moves with project(s) to other computers
- Maintains manifest
Cons
- Must repeat for every Project.
- Visual Studio 11 Beta installs the Windows 8 SDK. Both 32bit and 64bit projects use the 32bit resource tools. The default installation directory is
C:\Program Files (x86)\Windows Kits\8.0\bin\x86
. I like to setup an environment variable for this, as%WINSDK32BIN%
, referenced as a Visual Studio Macro as$(WINSDK32BIN)
. - In VS11B Solution Explorer, right-click on the project name, select Properties to pop up the Property Pages.
- In the left pane, expand Configuration Properties the left-click on VC++ Directories.
- In the right pane, expand General then left-click on Executable Directories to get the drop-down menu at the far right.
- Choose Edit from the drop-down menu and the Executable Directories pop-up appears.
- Double click in the top frame and enter the path to the WinSDK x86 bin directory.
- Confirm with OK, OK. You can now build and link your project without errors
.
Add WinSDK to system PATH
Pros
- Applies to all projects on a single computer.
- Maintains manifest.
Cons
- Does not move with project to a new computer.
- The
PATH
environment variable is always squeezed for space.
- Modify the
PATH
environment variable to include the WinSDK path. - Exit and restart Visual Studio 11 Beta.
Disable the Manifest
Pros
- Applies to all projects on a single computer.
- Moves with projects to other computers.
Cons
- Stops manifest creation, which helps address DLL Hell.
This disables manifest generation for all projects on a particular installation of Visual Studio 11 Beta.
- In VS11 Beta, open the Property Manager with View->Property Manager.
- Expand any project and then open either Debug or Release.
- Double-click on Microsoft.Cpp.Win32.user. (Note, for 64bit builds, you need to modify Microsoft.Cpp.x64.user in the same manner.)
- In the left pane, expand Common Properties and then Linker.
- Under Linker, click All Options.
- In the Look for options or switches: window (thank you, Microsoft!) type manifest without the quotes.
- Use the Generate Manifest drop-down and select No.
- Confirm with a couple OKs and you are ready to build sans manifest.
Done
Your Visual Studio 11 Beta now can link native code without manifest errors.