您好,登錄后才能下訂單哦!
要在Ubuntu上監(jiān)控C編譯器的編譯過程,你可以使用gcc
命令的輸出重定向功能將編譯過程的輸出保存到一個(gè)文件中
打開終端。
使用文本編輯器(如nano或vim)創(chuàng)建一個(gè)新的文本文件,例如compile_log.txt
,用于存儲(chǔ)編譯過程的輸出:
nano compile_log.txt
compile_log.txt
文件中,以便在編譯過程中捕獲標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯(cuò)誤:#!/bin/sh
exec > >(tee -i compile_log.txt) 2>&1
這將把標(biāo)準(zhǔn)輸出(stdout)和標(biāo)準(zhǔn)錯(cuò)誤(stderr)重定向到compile_log.txt
文件,并在文件中進(jìn)行實(shí)時(shí)編輯。
保存并關(guān)閉compile_log.txt
文件。
在終端中,使用gcc
命令編譯你的C程序,并將輸出重定向到剛剛創(chuàng)建的compile_log.txt
文件。例如,如果你的C源代碼文件名為main.c
,則可以使用以下命令:
gcc main.c -o main -Wall
這將編譯main.c
文件并生成一個(gè)名為main
的可執(zhí)行文件。編譯過程的輸出將被實(shí)時(shí)保存到compile_log.txt
文件中。
compile_log.txt
文件以獲取有關(guān)編譯過程的詳細(xì)信息。如果編譯成功,你將看到類似于以下的輸出:main.c: In function 'main':
main.c:10:2: warning: unused variable 'x' [-Wunused-variable]
main.c:10:2: warning: unused variable 'y' [-Wunused-variable]
main.c:14:1: error: expected expression before ';' token
main.c: In function 'main':
main.c:15:1: error: expected expression before ';' token
main.c: At top level:
main.c:17:2: error: expected '}' before ';' token
main.c:18:1: error: expected '}' before ';' token
main.c:19:1: error: expected '}' before ';' token
main.c:20:1: error: expected '}' before ';' token
main.c:21:1: error: expected '}' before ';' token
main.c:22:1: error: expected '}' before ';' token
main.c:23:1: error: expected '}' before ';' token
main.c:24:1: error: expected '}' before ';' token
main.c:25:1: error: expected '}' before ';' token
main.c:26:1: error: expected '}' before ';' token
main.c:27:1: error: expected '}' before ';' token
main.c:28:1: error: expected '}' before ';' token
main.c:29:1: error: expected '}' before ';' token
main.c:30:1: error: expected '}' before ';' token
main.c:31:1: error: expected '}' before ';' token
main.c:32:1: error: expected '}' before ';' token
main.c:33:1: error: expected '}' before ';' token
main.c:34:1: error: expected '}' before ';' token
main.c:35:1: error: expected '}' before ';' token
main.c:36:1: error: expected '}' before ';' token
main.c:37:1: error: expected '}' before ';' token
main.c:38:1: error: expected '}' before ';' token
main.c:39:1: error: expected '}' before ';' token
main.c:40:1: error: expected '}' before ';' token
main.c:41:1: error: expected '}' before ';' token
main.c:42:1: error: expected '}' before ';' token
main.c:43:1: error: expected '}' before ';' token
main.c:44:1: error: expected '}' before ';' token
main.c:45:1: error: expected '}' before ';' token
main.c:46:1: error: expected '}' before ';' token
main.c:47:1: error: expected '}' before ';' token
main.c:48:1: error: expected '}' before ';' token
main.c:49:1: error: expected '}' before ';' token
main.c:50:1: error: expected '}' before ';' token
main.c:51:1: error: expected '}' before ';' token
main.c:52:1: error: expected '}' before ';' token
main.c:53:1: error: expected '}' before ';' token
main.c:54:1: error: expected '}' before ';' token
main.c:55:1: error: expected '}' before ';' token
main.c:56:1: error: expected '}' before ';' token
main.c:57:1: error: expected '}' before ';' token
main.c:58:1: error: expected '}' before ';' token
main.c:59:1: error: expected '}' before ';' token
main.c:60:1: error: expected '}' before ';' token
main.c:61:1: error: expected '}' before ';' token
main.c:62:1: error: expected '}' before ';' token
main.c:63:1: error: expected '}' before ';' token
main.c:64:1: error: expected '}' before ';' token
main.c:65:1: error: expected '}' before ';' token
main.c:66:1: error: expected '}' before ';' token
main.c:67:1: error: expected '}' before ';' token
main.c:68:1: error: expected '}' before ';' token
main.c:69:1: error: expected '}' before ';' token
main.c:70:1: error: expected '}' before ';' token
main.c:71:1: error: expected '}' before ';' token
main.c:72:1: error: expected '}' before ';' token
main.c:73:1: error: expected '}' before ';' token
main.c:74:1: error: expected '}' before ';' token
main.c:75:1: error: expected '}' before ';' token
main.c:76:1: error: expected '}' before ';' token
main.c:77:1: error: expected '}' before ';' token
main.c:78:1: error: expected '}' before ';' token
main.c:79:1: error: expected '}' before ';' token
main.c:80:1: error: expected '}' before ';' token
main.c:81:1: error: expected '}' before ';' token
main.c:82:1: error: expected '}' before ';' token
main.c:83:1: error: expected '}' before ';' token
main.c:84:1: error: expected '}' before ';' token
main.c:85:1: error: expected '}' before ';' token
main.c:86:1: error: expected '}' before ';' token
main.c:87:1: error: expected '}' before ';' token
main.c:88:1: error: expected '}' before ';' token
main.c:89:1: error: expected '}' before ';' token
main.c:90:1: error: expected '}' before ';' token
main.c:91:1: error: expected '}' before ';' token
main.c:92:1: error: expected '}' before ';' token
main.c:93:1: error: expected '}' before ';' token
main.c:94:1: error: expected '}' before ';' token
main.c:95:1: error: expected '}' before ';' token
main.c:96:1: error: expected '}' before ';' token
main.c:97:1: error: expected '}' before ';' token
main.c:98:1: error: expected '}' before ';' token
main.c:99:1: error: expected '}' before ';' token
main.c:100:1: error: expected '}' before ';' token
main.c:101:1: error: expected '}' before ';' token
main.c:102:1: error: expected '}' before ';' token
main.c:103:1: error: expected '}' before ';' token
main.c:104:1: error: expected '}' before ';' token
main.c:105:1: error: expected '}' before ';' token
main.c:106:1: error: expected '}' before ';' token
main.c:107:1: error: expected '}' before ';' token
main.c:108:1: error: expected '}' before ';' token
main.c:109:1: error: expected '}' before ';' token
main.c:110:1: error: expected '}' before ';' token
main.c:111:1: error: expected '}' before ';' token
main.c:112:1: error: expected '}' before ';' token
main.c:113:1: error: expected '}' before ';' token
main.c:114:1: error: expected '}' before ';' token
main.c:115:1: error: expected '}' before ';' token
main.c:116:1: error: expected '}' before ';' token
main.c:117:1: error: expected '}' before ';' token
main.c:118:1: error: expected '}' before ';' token
main.c:119:1: error: expected '}' before ';' token
main.c:120:1: error: expected '}' before ';' token
main.c:121:1: error: expected '}' before ';' token
main.c:122:1: error: expected '}' before ';' token
main.c:123:1: error: expected '}' before ';' token
main.c:124:1: error: expected '}' before ';' token
main.c:125:1: error: expected '}' before ';' token
main.c:126:1: error: expected '}' before ';' token
main.c:127:1: error: expected '}' before ';' token
main.c:128:1: error: expected '}' before ';' token
main.c:129:1: error: expected '}' before ';' token
main.c:130:1: error: expected '}' before ';' token
main.c:131:1: error: expected '}' before ';' token
main.c:132:1: error: expected '}' before ';' token
main.c:133:1: error: expected '}' before ';' token
main.c:134:1: error: expected '}' before ';' token
main.c:135:1: error: expected '}' before ';' token
main.c:136:1: error: expected '}' before ';' token
main.c:137:1: error: expected '}' before ';' token
main.c:138:1: error: expected '}' before ';' token
main.c:139:1: error: expected '}' before ';' token
main.c:140:1: error: expected '}' before ';' token
main.c:141:1: error: expected '}' before ';' token
main.c:142:1: error: expected '}' before ';' token
main.c:143:1: error: expected '}' before ';' token
main.c:144:1: error: expected '}' before ';' token
main.c:145:1: error: expected '}' before ';' token
main.c:146:1: error: expected '}' before ';' token
main.c:147:1:
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。