1

I work on a c++ console project. this project has in msmpisdk platform. When I compiled in Visual Studio 2019 the error below occurred:

"Severity Code Description Project File Line Suppression State...Error MSB6006 "CL.exe" exited with code 2....C:\Program Files (x86)\Microsoft VisualStudio\2019\Enterprise\MSBuild\Microsoft\VC\v160-\Microsoft.CppCommon.targets 429."

I checked my code, it seems OK, also check ref lib of project, it seems OK.

I searched the web.

  1. All functions return a value.
  2. All variables set a value before using it.
  3. I restarted Visual Studio and my computer.
  4. I created new project and added the code, but the same error occurred.

but the same error occurred and my code doesn't compile.

mohmor
  • 31
  • 7
  • possible duplicate: https://stackoverflow.com/questions/13948990/error-msb6006-cl-exe-exited-with-code-2 – RoQuOTriX Sep 13 '19 at 08:54
  • Not a duplicate, this is a new VS2019 bug. The fix is released in version 16.3, currently in preview. https://developercommunity.visualstudio.com/content/problem/405001/error-msb6006-clexe-exited-with-code-2.html – Hans Passant Sep 13 '19 at 09:26

1 Answers1

0

at last I found the problem.

  • one of my variable ,initialized in algorithm .
  • but compiler can not detect variable initialized before and raise error.
  • see below code to see how this error raised.

#include "iostream"
class myclass1
{
    public: int _AMethod() { return 55; }
};

int main()
{
  myclass1* myVariable;
  int x = 0;
  if (x == 0)
  {
    myVariable = (myclass1*)malloc(sizeof(myclass1) * 5);
    //myVariable = init();
  }

  if (x == 0)
  {
    myVariable->_AMethod();
  }
}

now when compile this error occurred: Error MSB6006 "CL.exe" exited with code 2.

  • all things in algorithm ok..
  • but compiler raise error ..

this error can solved easily .. with init in definition, like below :

#include "iostream"
class myclass1
{
    public: int _AMethod() { return 55; }
};

int main()
{
  myclass1* myVariable=(myclass1*)malloc(sizeof(myclass1) * 5);
  int x = 0;
  if (x == 0)
  {
    //myVariable = (myclass1*)malloc(sizeof(myclass1) * 5);
    //myVariable = init();
  }

  if (x == 0)
  {
    myVariable->_AMethod();
  }
}

mohmor
  • 31
  • 7