1

Asking this question preemtively because there is not much to be found about this error code. It is rather trivial to solve, but cost me a lot of time to diagnose because no proper error message is given.

So what happened?

  • I added templated functions to my project
  • Now when the project compiles, A message pops up saying that CL.exe had a problem and needs to be closed
  • Visual Studio aborting the compilation with error MSB6006: "CL.exe" exited with code 1

The problem were syntax errors in my template functions. Who could have guessed that.

However, it was hard to find out, because these did not get reported. See my answer for how to determine which functions are defective.

The templated functions were in a .cpp included in the header, however, defining them completely in the header did not make any difference.

// foo.h

template <typename T>
void foo();

...

#include "foo.cpp"



// foo.cpp

template <typename T>
void foo() 
{
...
}
antipattern
  • 743
  • 1
  • 9
  • 20

3 Answers3

2

First you need to compile all .cpp files that include the templated functions seperately (select one in the project explorer, right click and "compile").

For me, the first hint was that some of them compiled, while for others cl.exe crashed.

The next step was to create a bogus.cpp file with just one function, where one by one I added calls to every templated function I created. After adding one: recompile. This went well until I got to the defective one, now the bogus.cppalso crashed cl.exe. Jackpot.

The last job was fixing the syntax error, which is annoying without error messages, but once this is done, bogus.cpp will compile again. Return to adding more function calls there until you have everything covered.

Hope I could help.

antipattern
  • 743
  • 1
  • 9
  • 20
0

What fixed it for me was that I had two instances of Visual Studio running, and while one of them was in the middle of a debugging session, I tried to compile the other instance. Stopping the debugging session fixed this error for me.

Leonardo Lopez
  • 1,113
  • 6
  • 20
  • 39
  • IIRC I was restarting my machine in the midst of diagnosing the problem, thus it is likely that I did not have multiple instances of VS open at that time. However, given the generic nature of the error message, I would not be surprised if there were several states of error resulting in this output. – antipattern Jul 11 '19 at 10:29
0

Encountered the same issue with simple form and VS2019. This does not seem to be related necessarily to a code issue, but potentially with VS itself.

  1. Took fresh checkout of code, built OK.
  2. Added new tab to existing form, CL.exe exited with code 1 error.
  3. Reverted code and added changes until error presented then could not get error to clear, event after clearing build output directories.
  4. Completely reverted build - CL.exe exited with code 1 error.
  5. Performed update of VS to 16.4.0 and restart PC - project builds OK.