Visual C++ build error: Failed to register output - c++

So I have this project I'm working on, and every time I build, it builds then executes the program, and then finishes with a build error. Why does this happen? I can't seem to find in the project properties where it would execute the file on the build.
It is kind of annoying, and it also ends up spawning an error. Here's an excerpt from the output
2>Link:
2> Generating code
2>c:\users\d0c\desktop\jlrria.lottery.repo\trunc\hash\hl_hashwrapper.h(277): warning C4706: assignment within conditional expression
2> Finished generating code
2> lottery-gui.vcxproj -> C:\Users\d0c\Desktop\jlrria.Lottery.repo\trunc\build\Release\lotteryslayer.exe
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(741,5): warning MSB3073: The command ""C:\Users\d0c\Desktop\jlrria.Lottery.repo\trunc\build\Release\lotteryslayer.exe" /RegServerRedirect" exited with code 2.
2> The previous error was converted to a warning because the task was called with ContinueOnError=true.
2> Build continuing because "ContinueOnError" on the task "Exec" is set to "true".<br>
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(744,5): error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions.
2>
2>Build FAILED.
So I guess I'm looking for help with two things
First and most importantly: Why is it executing the build program
Second: Why am I getting this error?
thanks.
ALSO
There are no items in the post build, otherwise, the log above would say "post-build" :p

Start with Visual Studio with Administrator rights. You can do so by right clicking on VS shortcut and Select Run As Administrator. Or create a shortcut where you would enable Run As Admin.
Reason:
Look at the error:
error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions.
Also, it seems to be a DLL/ActiveX control project. Look at: Linker->General->Register Output and set it to NO.

You are building an ATL project? Seems to be a bug in VS2010, http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/11f01ceb-52a4-438f-b7ef-727ce7a3e191 concerning ATL projects.

Related

VS Code Error when compiling C++ Program: 'cmd' is not recognized as an internal or external command

I attempted to follow through on VS Code's method on making C++ code work on their editor. I did this successfully on my laptop but when I tried compiling it, I was met with the error:
* Executing task: C/C++: g++.exe build active file
Starting build...
C:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\salty\Documents\Programming\C++ Scripts\myProgram\main.cpp" -o "C:\Users\salty\Documents\Programming\C++ Scripts\myProgram\main.exe"
'cmd' is not recognized as an internal or external command,
operable program or batch file.
Build finished with error(s).
* The terminal process failed to launch (exit code: -1).
* Terminal will be reused by tasks, press any key to close it.
This is the entire error message plus extra things in my editor.
If I try and copy and paste the command in the message into Windows Power Shell, it actually works (New .exe file appeared in the correct directory and runs without fault).
These are my environment variables for User, and these are my System variables.
I've tried uninstalling and re-installing and changing the paths around. I'm new to C++ programming and how compilers work in general, but I'm not sure why VS Studio says it doesn't recognize cmd among others it could've not recognized.
Why is it giving me this error?
Edit: I believe I didn't include a return 0; line in the program. Correcting this did not fix the issue.
I am not sure what I poked into place or if I just was too incompetent to realize something, however adding %SystemRoot%\system32 to my PSModulePath environment variables somehow fixed the issue, and since that action I have yet to replicate the compile error.
I don't know if adding that variable to my environments permanently fixed it or VS Studio needed a moment to process some things. Thanks anyways!

VisualStudio - Fatal error LNK1168: cannot open myfile.exe for writing

Sometime, while I try to compile my project, VisualStudio show me this error:
1>LINK : fatal error LNK1168: cannot open C:\Path\myfile.exe for writing
and It not allowes me to compile the project.
It seems that myfile.exe is open and running in background yet, although I closed it. I opened Win TaskManager but the file is not shown in the list of process running.
This error persists and the only solution I found is reboot the system, but it's a tedious way that give me crazy because this error recurs often.
Some ideas to resolve it? Someone had the same error before?
I had this error already many times. Though your myfile.exe is not shown in TaskManager, It is present in background yet. If you open the cmd as administator and type:
tasklist | FIND "myfile.exe"
You can see your process running.
So at this point type the command:
taskkill /IM myfile.exe /F
in order to force the process kill.
Now, if you try to compile your project again, you'll see the compiler is ok and the error is resolved.
Surely it's possible that this error will occur again, so I suggest you to create a .bat file that run the kill command, so you can resolve the problem quickly.
regarding: LNK1168
Microsoft has a web page dedicated to this error:
LNK1168
The first thing on the linked page is:
The linker can’t write to filename.
The rest of the page discusses the details of why the linker cannot write to the file.

Visual Studio 2015: C++ code analysis error C1253, unable to load model file 'res://mspft140.dll/300'

Visual Studio 2015 Community update 3, trying the C++ code analysis feature. The settings are as follows:
solution properties > code analysis settings > [all configurations] [all platforms] : microsoft native recommended settings
project properties > code analysis > [all configurations] [all platforms] : microsoft native recommended settings
Whenever I run analyze > run code analysis on solution I would always get a c1xx : fatal error C1253: Unable to load model file 'res://mspft140.dll/300'. This happens to every project, new or existing. MSDN is not particularly helpful about this one.
The string is a res protocol, so I checked if the dll mentioned is at its correct location (there are two actually, at c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ and c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64), and opened them with resedit. Both contain an XML resource named 300, so I don't see any reason for VS being unable to load it. Resetting the settings didn't help, full uninstall and reinstall (half a day wasted) did neither.
I also ran procmon with [Path] [contains] [mspft] filter while running the code analysis in VS, but the file system results are only SUCCESS and FILE LOCKED WITH ONLY READERS, which seems to be ok.
Did anyone experience this error? Does anyone have any surmises about its cause?
Update: After looking thoroughly through many more procmon captures with different filters I found out that cl.exe tries to open this registry key value: HKCR\PROTOCOLS\Handler\res\CLSID. Clearly it looks for the handler of the res protocol mentioned in the error output - and it's not there to be found, while many siblings of res key refer to some valid handlers, for example, http key has CLSID value of {79eac9e2-baf9-11ce-8c82-00aa004ba90b}. I guess that my quest for now is figuring out what that res CLSID is meant to be.
I was right in my assumption about the res protocol handler. The correct HKCR\PROTOCOLS\Handler\res\CLSID value is {3050f3bc-98b5-11cf-bb82-00aa00bdce0b} (which refers to C:\Windows\System32\mshtml.dll). For some reason my registry was missing it; as soon as I added the value, the code analysis started working without errors.
I hope this helps someone, although I believe the bug is extremely rare.

Building via MSBuild fails when run as System User

We are using Visual Studio 2012 to build our C++ application
If I run from the commandline in my source folder:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release /p:Platform=Win32 Myproject2012.sln
it works fine. If it's run via the Buildscript of my buildserver (Atlassian bamboo) I get a lot of errors. The first two lines..
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(347,5): error MSB4018: The "CL" task failed unexpectedly. [C:\data\bamboo-home\xml-data\build-dir\XXX-IMB-JOB1\XXX\common\common.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(347,5): error MSB4018: System.TypeInitializationException: The type initializer for 'Microsoft.Build.Utilities.FileTracker' threw an exception. ---> System.IO.DirectoryNotFoundException: Das System kann den angegebenen Pfad nicht finden. (Exception from HRESULT: 0x80070003) [C:\data\bamboo-home\xml-data\build-dir\XXX-IMB-JOB1\XXX\common\common.vcxproj]
What can be the reason for this behaviour?
You can run the build outside of Bamboo as system if you use Sysinternals psexec.
psexec -i -s cmd.exe
Then try C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release /p:Platform=Win32 Myproject2012.sln
Then create a shell that have elevated permissions and retry.
Should help see if its a permissions thing or a path thing. Ive tried building C++ as system and it seems PK.
Or it could be this:
MSBUILD MSB4018 error
I found the problem
The System Account has a default temp directory which msbuild doesn't like
I changed it to "c:\temp" no it works!
If someone else has the problem, you can change it in the registry
HKEY_USERS\.DEFAULT\Environment

Problem while building a .dll (Visual C++)

I am trying to build a .dll in order to link it to one of my projects. But the build always fails : I got these messages in the output and I don't know what it means. It seems that something is missing, but I couldn't find what.
I am trying to link a Mesher called Netgen
http://www.hpfem.jku.at/netgen/
1>adfront2.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1> Creating library D:\Documents\Visual Studio 2008\Projects\converter/lib\nglib.lib and object D:\Documents\Visual Studio 2008\Projects\converter/lib\nglib.exp
1>Embedding manifest...
1>Performing Post-Build Event...
1>Environment variable NETGENDIR not found.... using default location!!!
1>POSTBUILD Script for nglib ........
1>Installing required files into XXX\Netgen\windows....\nglib-instNoOCC_Win32 ....
1>File not found - nglib.dll
1>0 File(s) copied
1>POSTBUILD Script for nglib FAILED..... Error copying the nglib DLL into install folder!!!
1>Project : error PRJ0002 : Error result 1 returned from 'C:\Windows\SysWow64\cmd.exe'.
1>Build log was saved at "file://D:\Documents\Visual Studio 2008\Projects\converter\BuildLog_nglib.htm"
1>nglib - 1 error(s), 49 warning(s)
I hope I am clear enough and thank you by advance for your help.
seems this NetGen lib's project wants to run a post-build event in which it tries to copy the main output (the nglib.dll) to the directory NETGENDIR (which is supposed to be an environment variable). This fails beccuse the dll isn't found.
Either disable the post build event, or check with the NetGen lib's creator what they expect here, there seems to be a mismatch between the project's output dir and the postbuild event.
Would also be nice to see the postbuild event from the vcproj file, maybe you can post it?
You need read, by example the output line:
1>Environment variable NETGENDIR not found.... using default location!!!
After that I suggest that you must read the documentation about how define a enviroment variable named: NETGENDIR