Y86-64模擬器的安裝與出現對'matherr'未定義引用問題的解決
一. Y86-64模擬器的安裝
我是參照這位博主的文章安裝的模擬器安裝,想安裝GUI版本的,到了第五步編譯的過程中出現了對'matherr'未定義引用的錯誤.
二. 解決問題,編譯GUI介面
進入sim目錄:cd sim
輸入make clean; make
1.編譯時出現錯誤,make後輸出的資訊如下
(cd misc; make all)
make[1]: 進入目錄“/home/dragon/sim/misc”
gcc -Wall -O1 -g -c yis.c
gcc -Wall -O1 -g -c isa.c
gcc -Wall -O1 -g yis.o isa.o -o yis
gcc -Wall -O1 -g -c yas.c
flex yas-grammar.lex
mv lex.yy.c yas-grammar.c
gcc -O1 -c yas-grammar.c
gcc -Wall -O1 -g yas-grammar.o yas.o isa.o -lfl -o yas
bison -d hcl.y
flex hcl.lex
gcc -O1 node.c lex.yy.c hcl.tab.c outgen.c -o hcl2c
make[1]: 離開目錄“/home/dragon/sim/misc”
(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5")
make[1]: 進入目錄“/home/dragon/sim/pipe”
# Building the pipe-std.hcl version of PIPE
../misc/hcl2c -n pipe-std.hcl < pipe-std.hcl > pipe-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
../misc/isa.c -L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5 -lm
/tmp/ccuL1R7t.o:(.data.rel+0x0):對‘matherr’未定義的引用
collect2: error: ld returned 1 exit status
Makefile:42: recipe for target 'psim' failed
make[1]: *** [psim] Error 1
make[1]: 離開目錄“/home/dragon/sim/pipe”
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2
由加粗欄位知進入pipe目錄並編譯psim.c和pipe-std.c時出現了對'matherr'未定義引用的錯誤
我們進入psim.c,將包含matherr的語句註釋掉,總共有兩行
2.
繼續使用make clean;make
輸出資訊為
rm -f *~ core
(cd misc; make clean)
make[1]: 進入目錄“/home/dragon/sim/misc”
rm -f *.o *.yo *.exe yis yas hcl2c mux4 *~ core.*
rm -f hcl.tab.c hcl.tab.h lex.yy.c yas-grammar.c
make[1]: 離開目錄“/home/dragon/sim/misc”
(cd pipe; make clean)
make[1]: 進入目錄“/home/dragon/sim/pipe”
rm -f psim pipe-*.c *.o *.exe *~
make[1]: 離開目錄“/home/dragon/sim/pipe”
(cd seq; make clean)
make[1]: 進入目錄“/home/dragon/sim/seq”
rm -f ssim ssim+ seq*-*.c *.o *~ *.exe *.yo *.ys
make[1]: 離開目錄“/home/dragon/sim/seq”
(cd y86-code; make clean)
make[1]: 進入目錄“/home/dragon/sim/y86-code”
rm -f *.o *.yis *~ *.yo *.pipe *.seq *.seq+ core
make[1]: 離開目錄“/home/dragon/sim/y86-code”
(cd ptest; make clean)
make[1]: 進入目錄“/home/dragon/sim/ptest”
rm -f *.o *~ *.yo *.ys
make[1]: 離開目錄“/home/dragon/sim/ptest”
(cd misc; make all)
make[1]: 進入目錄“/home/dragon/sim/misc”
gcc -Wall -O1 -g -c yis.c
gcc -Wall -O1 -g -c isa.c
gcc -Wall -O1 -g yis.o isa.o -o yis
gcc -Wall -O1 -g -c yas.c
flex yas-grammar.lex
mv lex.yy.c yas-grammar.c
gcc -O1 -c yas-grammar.c
gcc -Wall -O1 -g yas-grammar.o yas.o isa.o -lfl -o yas
bison -d hcl.y
flex hcl.lex
gcc -O1 node.c lex.yy.c hcl.tab.c outgen.c -o hcl2c
make[1]: 離開目錄“/home/dragon/sim/misc”
(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5")
make[1]: 進入目錄“/home/dragon/sim/pipe”
# Building the pipe-std.hcl version of PIPE
../misc/hcl2c -n pipe-std.hcl < pipe-std.hcl > pipe-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
../misc/isa.c -L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5 -lm
./gen-driver.pl -n 4 -f ncopy.ys > sdriver.ys
../misc/yas sdriver.ys
./gen-driver.pl -n 63 -f ncopy.ys > ldriver.ys
../misc/yas ldriver.ys
make[1]: 離開目錄“/home/dragon/sim/pipe”
(cd seq; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5")
make[1]: 進入目錄“/home/dragon/sim/seq”
# Building the seq-std.hcl version of SEQ
../misc/hcl2c -n seq-std.hcl <seq-std.hcl >seq-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o ssim \
seq-std.c ssim.c ../misc/isa.c -L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5 -lm
/tmp/cczSQwXi.o:(.data.rel+0x0):對‘matherr’未定義的引用
collect2: error: ld returned 1 exit status
Makefile:42: recipe for target 'ssim' failed
make[1]: *** [ssim] Error 1
make[1]: 離開目錄“/home/dragon/sim/seq”
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2
由以上資訊知pipe目錄裡的內容已經編譯完成了,在進入seq目錄時出現了編譯錯誤
同第一步的做法,在seq-std.c和ssim.c檔案中尋找有matherr 的行,在ssim.c中找到了兩行相關資訊,註釋掉
3.接下來重新編譯
make clean; make
輸出以下資訊
rm -f *~ core
(cd misc; make clean)
make[1]: 進入目錄“/home/dragon/sim/misc”
rm -f *.o *.yo *.exe yis yas hcl2c mux4 *~ core.*
rm -f hcl.tab.c hcl.tab.h lex.yy.c yas-grammar.c
make[1]: 離開目錄“/home/dragon/sim/misc”
(cd pipe; make clean)
make[1]: 進入目錄“/home/dragon/sim/pipe”
rm -f psim pipe-*.c *.o *.exe *~
make[1]: 離開目錄“/home/dragon/sim/pipe”
(cd seq; make clean)
make[1]: 進入目錄“/home/dragon/sim/seq”
rm -f ssim ssim+ seq*-*.c *.o *~ *.exe *.yo *.ys
make[1]: 離開目錄“/home/dragon/sim/seq”
(cd y86-code; make clean)
make[1]: 進入目錄“/home/dragon/sim/y86-code”
rm -f *.o *.yis *~ *.yo *.pipe *.seq *.seq+ core
make[1]: 離開目錄“/home/dragon/sim/y86-code”
(cd ptest; make clean)
make[1]: 進入目錄“/home/dragon/sim/ptest”
rm -f *.o *~ *.yo *.ys
make[1]: 離開目錄“/home/dragon/sim/ptest”
(cd misc; make all)
make[1]: 進入目錄“/home/dragon/sim/misc”
gcc -Wall -O1 -g -c yis.c
gcc -Wall -O1 -g -c isa.c
gcc -Wall -O1 -g yis.o isa.o -o yis
gcc -Wall -O1 -g -c yas.c
flex yas-grammar.lex
mv lex.yy.c yas-grammar.c
gcc -O1 -c yas-grammar.c
gcc -Wall -O1 -g yas-grammar.o yas.o isa.o -lfl -o yas
bison -d hcl.y
flex hcl.lex
gcc -O1 node.c lex.yy.c hcl.tab.c outgen.c -o hcl2c
make[1]: 離開目錄“/home/dragon/sim/misc”
(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5")
make[1]: 進入目錄“/home/dragon/sim/pipe”
# Building the pipe-std.hcl version of PIPE
../misc/hcl2c -n pipe-std.hcl < pipe-std.hcl > pipe-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
../misc/isa.c -L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5 -lm
./gen-driver.pl -n 4 -f ncopy.ys > sdriver.ys
../misc/yas sdriver.ys
./gen-driver.pl -n 63 -f ncopy.ys > ldriver.ys
../misc/yas ldriver.ys
make[1]: 離開目錄“/home/dragon/sim/pipe”
(cd seq; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5")
make[1]: 進入目錄“/home/dragon/sim/seq”
# Building the seq-std.hcl version of SEQ
../misc/hcl2c -n seq-std.hcl <seq-std.hcl >seq-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o ssim \
seq-std.c ssim.c ../misc/isa.c -L/usr/lib/x86_64-linux-gun/ -ltk8.5 -ltcl8.5 -lm
make[1]: 離開目錄“/home/dragon/sim/seq”
(cd y86-code; make all)
make[1]: 進入目錄“/home/dragon/sim/y86-code”
../misc/yas abs-asum-cmov.ys
../misc/yas abs-asum-jmp.ys
../misc/yas asum.ys
../misc/yas asumr.ys
../misc/yas asumi.ys
../misc/yas cjr.ys
../misc/yas j-cc.ys
../misc/yas poptest.ys
../misc/yas pushquestion.ys
../misc/yas pushtest.ys
../misc/yas prog1.ys
../misc/yas prog2.ys
../misc/yas prog3.ys
../misc/yas prog4.ys
../misc/yas prog5.ys
../misc/yas prog6.ys
../misc/yas prog7.ys
../misc/yas prog8.ys
../misc/yas prog9.ys
../misc/yas prog10.ys
../misc/yas ret-hazard.ys
make[1]: 離開目錄“/home/dragon/sim/y86-code”
成功啦!!!
三.檢驗GUI介面是否安裝成功
以psim為例
進入pipe目錄: cd pipe
執行圖形介面:./psim -t -g ../y86-code/asum.yo
出現了一個圖形介面,錯誤解決(暫時沒有發現註釋掉matherr行後的問題,可以正常學習csapp第四章的內容)