mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file ... Access is denied
Asked Answered
A

14

49

I often have this problem even when I build a new C++ project and try to build a release file.

I use Visual studio 2008. One thing that may cause this problem is my code is saved on the server disk, not on local hard disk.

mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "..\Release\PGTS_version17C.exe". The process cannot access the file because it is being used by another process.

Anyone know how to solve this? Thanks.

Abdicate answered 23/9, 2010 at 4:11 Comment(0)
L
52

If you are embedding a manifest file, your anti-virus program may lock and scan your exe file before embedding the manifest.

I recommend disabling anti-virus from reading your DEBUG and RELEASE output folders.

Ly answered 14/12, 2010 at 17:26 Comment(5)
For the sake of completeness symantec.com/business/support/…Incoherence
You are a lifesaver! +1, that helped me out a lot.Overdevelop
Even WindowsDefender seems to stay in this way.Singh
I added the folders to the list of exclusions, tenforums.com/tutorials/…Dynameter
In case you have Windows Defender, use these steps and turn off Real-time Protection: wisecleaner.com/how-to/…Dodgson
L
16

Go to Debug and/or Release folder(s), right click and unset, recursively, the Read-Only property.

Found this tip in the MSDN Community and solved my problem!

Loment answered 15/3, 2014 at 0:39 Comment(2)
This is exactly what I needed.Hsinking
That wasnt the problem, as the error still occurred. It appears to be some intermittent issue - sometimes the compile works, sometimes it doesn't ... showed up once system was upgraded to Windows 10 (with whatever payload my company used along with that image). Never an issue under my old Windows 7 system.Nard
I
14

It it's not a permissions or actual file access problem (AV)...

You can add a flag to make the compiler check the validity of the manifest.

This validation will fix the problem so you'll never have to rebuild it again.
This is very important for anyone who's running an actual Build-Machine or automatic buildscript where you don't want to manually interfere:

Add this flag:
Project properties -> Configuration Properties -> Manifest Tool -> Command Line -> Additional options:

/validate_manifest
Inerney answered 9/2, 2017 at 12:32 Comment(1)
That solved my issue. Typically a Build-Machine or automatic buildscript as you said.Instigation
R
8

Funny enough I had the exact same error and a "rebuild" on the whole project solved it.

Revet answered 10/9, 2013 at 12:12 Comment(0)
O
5

disabling the Anti-Virus worked for me.

Opportina answered 8/3, 2014 at 23:43 Comment(2)
Any particular brand of Antivirus?Jae
If avast antivirus is installed, then this issue occures.Compete
B
4

If you need not generate Manifest file, just set it off it will resolve the problem.

Goto Project(right click)

properties

Linker

Manifest Files

Generate Manifest

change it Yes to No

It resolve the problem for me on VS2008 without disabling Anti-virus. ;)

Enjoy :)

Battista answered 11/2, 2016 at 5:57 Comment(1)
Worked for me on VS2010 as wellEtom
C
3

Open visual studio 2010 as "Run as administrator" and Rebuild again.

Chamade answered 3/12, 2014 at 7:0 Comment(0)
S
3

I worked around this with a "wrapper" program for mt.exe, one that reran it until it succeeded. Save the following code as mt-wrapper.cpp:

#include <windows.h>
#include <stdio.h>
#include <process.h>

// Build from a Visual Studio Command Prompt with "cl /O2 /Gy /Femt.exe mt-wrapper.cpp"

int __cdecl wmain(int argc, WCHAR **argv, WCHAR **env)
{
    // Stop outputting text.
    fclose(stdout);
    fclose(stderr);

    // Run the original mt.exe, which has been renamed to mt-orig.exe .
    for (;;)
    {
        // Try to run the original mt.
        intptr_t iStatus = _wspawnve(_P_WAIT, L"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\mt-orig.exe", argv + 1, env);
        if (iStatus == 0)
            break;

        // Try again, after a short wait.
        ::Sleep(100);
    }

    return 0;
}

Build this program, go to your C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin folder, rename the old mt.exe to mt-orig.exe (and the mt.exe.config to mt-orig.exe.config), and put this wrapper program in there as mt.exe. Now, when you build, it will retry running the original mt.exe until it succeeds.

Oddly, MSBuild doesn't seem to check for a zero status when deciding that mt.exe has succeeded — it seems to look for error messages written to stdout/stderr. So this program closes both of those before spawning the original mt.exe. Anyone feeling industrious can apply the advice found here to save the output of the successful run of the original mt.exe, and output it to stdout/stderr.

Stavros answered 31/8, 2016 at 18:57 Comment(3)
I have used your code as base for project on github. Hope you won't mind.Shingly
@ElDorado: Of course I don't mind! Thanks for the compliment!Stavros
Thank you for this solution! Note: with Windows 10 / VS 2019 I had to change the path to: C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x86\\mt-orig.exe There is also a parallel file: ...\\x64\\mt-orig.exe Now my compilation is stuck on: Embedding manifest... From this I gather that your code works as intended, but doesn't solve the problem in my case.Stiegler
L
1

Try this:

  1. Disable AV
  2. Temporary rename your exe so it doesn't contain any of the words UAC magic words (install, setup, patch, upgrade)
  3. make sure you have write permissions
  4. use mt command to inject the manifest
  5. rename back your exe
Labarum answered 3/10, 2016 at 11:37 Comment(0)
S
1

In my case none of the suggestions presented here worked. I am using Ninja build with VS 2019, and build fails randomly in only Jenkins. Disable manifest is not an option in our case. As a workaround I disable manifest during link stage, however added a custom target with POST_BUILD step to embed manifest using mt.exe.

disable manifest during link stage

target_link_options(target_name PRIVATE /MANIFEST:NO)

add post build step. change #1 (used for exe) to #2 if using dll

add_custom_command(TARGET target_name POST_BUILD
                COMMAND mt.exe -manifest manifest_file -outputresource:$<TARGET_FILE:target_name>;#1
                COMMENT "Adding custom manifest on target_name" 
                VERBATIM)

With above workaround no failure in Jenkins server now.

Spermatium answered 27/9, 2022 at 21:6 Comment(0)
C
0

If you're using Hudson/Jenkins to create releases restarting it solved the problem for me.

Cowl answered 19/11, 2014 at 9:59 Comment(0)
S
0

I solved this error by stopping and disabling the 'Timing Service' (part of FireEye)

Stapleton answered 8/10, 2015 at 13:49 Comment(0)
C
0

If your project is stored in Dropbox, you have to quit Dropbox to build. This is also an issue when using Unreal Engine.

Cini answered 16/11, 2021 at 9:21 Comment(2)
If this is an already known issue, could you maybe provide a link to where it is documented?Shovel
I dont know if this is officially documented anywhere; but I found out by asking on an Unreal Engine facebook group, and got this tip from someone. Dropbox makes for some strange behaviour when saving, not sure exactly what. I only use github now.Cini
N
0

I had the same issue. And disabling the anti-virus solution was not an option because Company policy mandated that anti-virus solutions could not be disabled. And Company policy did not allow to specify an exception folder for the anti-virus scan. But I found that every time I build the solution(not rebuild) the binary files(dlls or exes) locked by anti virus solution changed. So after trying to build the solution 10 or more times I finally succeeded in building the whole solution. Just try to build the solution many times after first time rebuild.

Nonoccurrence answered 23/5, 2024 at 1:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.