Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error MSB6006: "CL.exe" exited with code 2

I'm writing with visual c++ and when I compile this error occures:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(147,5): error MSB6006: "CL.exe" terminato con il codice 2.

Does anyone know why?

Thanks in advance!

like image 474
tiavec88 Avatar asked Dec 19 '12 09:12

tiavec88


2 Answers

You can actually see the proper error messages instead of Microsoft's arbitrary error codes. But since the error list is always forcibly made visible when there are errors, it isn't quite so obvious. Next to the tab Error List is another tab Output, which shows the raw error output. I'm not sure if that tab exists in all versions since I'm using 2019, but there might be something very similar in older versions anyways. Differently named perhaps, or an entirely separate window instead of grouped with Error List.

In the case of another answerer here that exact tab would've shown: error C4700: uninitialized local variable 'm' used

Which would have saved him from having to dig through all his code. =]

And if you forget a return value for a function that requires it, you'll see: error C4716: 'foo': must return a value

like image 55
Sahbi Avatar answered Sep 22 '22 13:09

Sahbi


This happened me for a variety of different reasons:

1) I forgot to add a return statement to a non-void function.

2) I tried to use an uninitialized pointer.

3) I wrote a loop like for(int i=i;...) instead of for(int i=0;...)

You can check your code for these and it may help.

like image 42
Ali Ihsan Elmas Avatar answered Sep 20 '22 13:09

Ali Ihsan Elmas