0

I am running a mingw32-make command directly in PowerShell to build a C project.

However, the output sometimes get completely messed up, eg part of one line is inserted into another line etc. Sometimes this makes reading the output impossible.

It seems that the output is consistent between two runs, ie for certain project state it will always produce the same messed up output.

I tried dumping the output to a txt file as mingw32-make > log.txt. I get clear output in the text file, but all error reports are missing! It just says "Compilation error" without actual error report.

Any ideas how can this be fixed?

5
  • 1
    you are probably seeing output via more than one stream. they can get out of sequence ... especially the *-Host stream and the success stream. try redirecting ALL the streams to your file.
    – Lee_Dailey
    Dec 4, 2020 at 20:01
  • That did the trick. I was redirecting only stdout to a file, but it did not occur to me that compilation errors are reported in stderr stream. I can clearly read all errors now in a file! This is the command: mingw32-make 2>&1 > log.txt - this redirects stream 2 to stream 1 (stderr to stdout), and dumps all to file log.txt. Thanks for good idea! Feel free to post your comment as an answer, so I can accept it. Dec 4, 2020 at 20:12
  • kool! glad to help [grin] ... and i added an Answer that seems to cover it. if you think it otta be modified, please let me know.
    – Lee_Dailey
    Dec 4, 2020 at 20:19
  • Maybe you could consider including the command that I used to dump both streams to a file? Just to have everything in one place. Dec 4, 2020 at 21:12
  • 1
    done as you requested ... [grin]
    – Lee_Dailey
    Dec 4, 2020 at 22:46

1 Answer 1

1

what you describe sounds like mingw32-make is sending to more than one stream. mingling output like that is similar to what happens when you mix Write-Host and Write-Output calls. the 1st goes [more or less] directly to the host, but the 2nd goes to the success stream and then to the host.

the simplest solution is likely to just redirect all the streams to your file, OR to combine the ones you want & Tee-Object the result to the screen and your file. [grin]

take a look at Get-Help about_Redirection for details.

i see that you used mingw32-make 2>&1 > log.txt. i could not specify any particular stream since i have no way to test that particular utility. i suspect i would have gone with mingw32-make *> log.txt to redirect all the streams. your pattern is better in that it avoids overdoing things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.