MrEngman
Posts: 3939
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Compiler error and warning messages

Wed Jun 06, 2012 3:27 pm

When compiling code are the error and warning messages saved anywhere or once off the screen they're gone forever? I had a long search through a load of different log files in /var/log/ and couldn't find anything.

If they are not saved how can I get the compiler to save them somewhere?
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: Compiler error and warning messages

Wed Jun 06, 2012 3:44 pm

Several answers because there is very little detail about your environment.

1. It depends on which compiler you are using. If you are using something like gcc, you can use
gcc myfile.c > log.txt

Or you may have to use
gcc myfile.c 2> log.txt

2. If you are using LXTerminal, you can scroll up using the scrollbar on the right-hand side.

3. You could be much better off using an IDE (Integrated Development Environment) such as Geany.
Last edited by bredman on Wed Jun 06, 2012 3:46 pm, edited 1 time in total.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Compiler error and warning messages

Wed Jun 06, 2012 3:45 pm

when I hit an issue like this I SSH into it and try and compile from the SSH terminal. That way I can scroll back through the screen. There's probably a better way to do that or a way without sshing into it.
Dear forum: Play nice ;-)

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: Compiler error and warning messages

Wed Jun 06, 2012 3:52 pm

I prefer to use g++ ...... &>1.txt this will send both stdout and stderr to the file. It also works with any other program you wish to use.

To preview once done use more 1.txt to page through the file

Jon

MrEngman
Posts: 3939
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Compiler error and warning messages

Wed Jun 06, 2012 4:00 pm

I'm trying to compile the kernel using the RasPi with the command:

Code: Select all

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k
It obviously takes hours and most of the time the screen is blank unless I press a key to bring it up again. I have caught a couple of errors/warnings on screen but though it would be far more convenient to get the compiler to save errors somewhere.

Can I just redirect error output to a file e.g using say:

Code: Select all

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k 2>compile_errors.txt
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Compiler error and warning messages

Wed Jun 06, 2012 4:26 pm

Simple redirection ought to work - many example command lines have already been posted here.

But I suggest that for this and similar problems, the "script" approach is better. The script command allows you to run a command line (or just an interactive shell) normally, with all input and output visible, while saving all of the terminal dialog to a file. There is a (more or less) standard Unix command called "script", that you can read about with "man script", that is basically a proof-of-concept implementation of the idea.

However, I find that the built-in command has some quirky limitations, so I prefer this implementation, in Expect, which I use all the time:

begin 644 Script.zip
M4$L#!!0````(`,A1(22>)!G:C0$``"\#```&`!4`4V-R:7!T550)``.XI*LT
M)H//3U5X!`#U`?4!C9(Q3\,P$(7G^%<\0A`@4=HR`AT8D!@ZP9A$R*27-%+B
M1+9;0&WZVSD[I;2`!),EW[MWWSW[^`C#A='#EU(-Z:VES&(P$(8L-&6-GN'1
M'Z4J1)EC%5<5J<+.$4E=+%/<X@KK-6)-!7=S*\)!$LL\#1%76JJ">B5&&*4I
M)A.,.JQ$X`;D)7O)FF#?6S*9+ELK@DS:;(X5O5$&76.0(_K4=2+H0)6A'P:'
MH\88IR+PM,9J)D?6U*W4WW4.B7%EF'JD/T;OS0[VXKEK6U(^'E;T6-[\<-05
M6,10G1!54SP[VR]S3EO-GA>&-,)$15MCV_C]<+K3G4+::\2VK,E867/:>:-K
M:7&2I9>)"O=]-L89&-NT6U`FO,!&NUM-9E%3HES+[V\Z]H%P+=YFXM8R<ZHJ
M1*269T\/]]/I>9?N%\S<K=_*5X7(WX@^L&!%2\GEON(F<`BELJ2E^VL,PQ;,
M&SJS'?^T*0KW<F9A7+XT8]B;S^@Z)"+8=6KN_!GJS2]F_>+.BA'^';K[/!59
M\A%_`%!+`0(7`Q0````(`,A1(22>)!G:C0$``"\#```&``T```````$```#M
M@0````!38W)I<'155`4``[BDJS15>```4$L%!@`````!``$`00```,8!````
!````
`
end
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

MrEngman
Posts: 3939
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Compiler error and warning messages

Wed Jun 06, 2012 4:34 pm

Joe Schmoe wrote:Simple redirection ought to work - many example command lines have already been posted here.

But I suggest that for this and similar problems, the "script" approach is better. The script command allows you to run a command line (or just an interactive shell) normally, with all input and output visible, while saving all of the terminal dialog to a file. There is a (more or less) standard Unix command called "script", that you can read about with "man script", that is basically a proof-of-concept implementation of the idea.

However, I find that the built-in command has some quirky limitations, so I prefer this implementation, in Expect, which I use all the time:

begin 644 Script.zip
M4$L#!!0````(`,A1(22>)!G:C0$``"\#```&`!4`4V-R:7!T550)``.XI*LT
M)H//3U5X!`#U`?4!C9(Q3\,P$(7G^%<\0A`@4=HR`AT8D!@ZP9A$R*27-%+B
M1+9;0&WZVSD[I;2`!),EW[MWWSW[^`C#A='#EU(-Z:VES&(P$(8L-&6-GN'1
M'Z4J1)EC%5<5J<+.$4E=+%/<X@KK-6)-!7=S*\)!$LL\#1%76JJ">B5&&*4I
M)A.,.JQ$X`;D)7O)FF#?6S*9+ELK@DS:;(X5O5$&76.0(_K4=2+H0)6A'P:'
MH\88IR+PM,9J)D?6U*W4WW4.B7%EF'JD/T;OS0[VXKEK6U(^'E;T6-[\<-05
M6,10G1!54SP[VR]S3EO-GA>&-,)$15MCV_C]<+K3G4+::\2VK,E867/:>:-K
M:7&2I9>)"O=]-L89&-NT6U`FO,!&NUM-9E%3HES+[V\Z]H%P+=YFXM8R<ZHJ
M1*269T\/]]/I>9?N%\S<K=_*5X7(WX@^L&!%2\GEON(F<`BELJ2E^VL,PQ;,
M&SJS'?^T*0KW<F9A7+XT8]B;S^@Z)"+8=6KN_!GJS2]F_>+.BA'^';K[/!59
M\A%_`%!+`0(7`Q0````(`,A1(22>)!G:C0$``"\#```&``T```````$```#M
M@0````!38W)I<'155`4``[BDJS15>```4$L%!@`````!``$`00```,8!````
!````
`
end
Sorry but that has just got me totally confused :shock:
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Compiler error and warning messages

Wed Jun 06, 2012 4:39 pm

I would start out by reading "man script", which will give you the basic idea - and you can start playing around with the built-in "script" command.

Then, I would suggest "man uudecode" and this will lead you to figuring out how to decode my uuencoded post (which is necessary, because the "Upload attachments" functionality is busted here). Then you can unzip the resulting file (Script.zip) and get the Script command. Then you can figure out how to put that in a file and make it executable, then finally all your efforts will be rewarded. And, you will learn about the wonderful "Expect" command as well.

All in the spirit of what the Pi is all about, doncha know...?
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: Compiler error and warning messages

Wed Jun 06, 2012 5:02 pm

if you do

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k 2>compile_errors.txt &

This will detach the build from the console and make it run in the background (the & does the detach) you can then follow the output of the error file by doing

tail -f compile_errors.txt

( use CTRL + c to exit the tail program).

MrEngman
Posts: 3939
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Compiler error and warning messages

Wed Jun 06, 2012 5:12 pm

Joe Schmoe wrote:I would start out by reading "man script", which will give you the basic idea - and you can start playing around with the built-in "script" command.

Then, I would suggest "man uudecode" and this will lead you to figuring out how to decode my uuencoded post (which is necessary, because the "Upload attachments" functionality is busted here). Then you can unzip the resulting file (Script.zip) and get the Script command. Then you can figure out how to put that in a file and make it executable, then finally all your efforts will be rewarded. And, you will learn about the wonderful "Expect" command as well.

All in the spirit of what the Pi is all about, doncha know...?
The Pi has certainly got my mind churning ;) It shouldn't be so bad after a while as I used to be very involved in Linux but a very, very long time ago with Linux 0,x.x and 1.x.x, helping with LSI Logic SCSI driver development. Its just a real problem trying to remember how to do even the most simplest of things at the moment. Feels like being back at primary school.

Anyway I'm buried in trying to sort out how git works at the moment so I can get hold of older versions of code for something I'm looking at but I shall try and see what script is all about when I can find a few moments spare.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 3939
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Compiler error and warning messages

Wed Jun 06, 2012 5:21 pm

jmacey wrote:if you do

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k 2>compile_errors.txt &

This will detach the build from the console and make it run in the background (the & does the detach) you can then follow the output of the error file by doing

tail -f compile_errors.txt

( use CTRL + c to exit the tail program).
Thanks for that. Just wasn't sure if redirecting the output of make was valid or not.

Normally I just login to a second terminal while make is running so I should be able to see what's happening to the compile_errors.txt file from there. So no need to worry about tail for the moment I think but another useful tip all the same.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Return to “General programming discussion”