Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio linker can't write to [hex number]

I am getting an error message from Visual Studio's C++ linker:

error LNK1108: cannot write file at 0xFB296C

The hex value changes with every build. This error doesn't occur on any of my peer's machines, so it's something in my environment.

MSDN suggests that one of the reasons for this error is insufficient disk space, but I have 155 GB free. As far as I can tell, my solution is configured to write all files locally.

Configuring the linker to use /VERBOSE and /LTCG:STATUS, I see that the error occurs towards the end of the run, when it comes time to merge metadata:

9> Finished searching libraries
9> Merging metadata
9> Finished merging metadata
9> LINK : fatal error LNK1108: cannot write file at 0x2E12984

Has anybody encountered this sort of problem before? How can I troubleshoot it?

I'm using Visual Studio 2013 Ultimate, Update 2.

like image 701
Justin R. Avatar asked Oct 31 '22 21:10

Justin R.


1 Answers

The solution is to delete the WINMD files within the solution. The fact that the linker was failing to overwrite the merged metadata (according to the log) was the clue. That lead me to reading about Windows Metadata (.winmd) files. I used ILDASM to have a look at the file, and the tool reported that it's corrupt. After deleting the generated winmd files, I am able to compile, link and run normally.

I once had a similar problem with SOU files. Maybe Visual Studio needs a "Super Clean" feature, similar to "Build > Clean Solution" that deletes all generated files.

like image 153
Justin R. Avatar answered Nov 15 '22 05:11

Justin R.