Ubuntu tk.h在/usr/include中查找tcl.h,但tcl.h在/usr/include/tcl中。我不知道';我没有写入tk.h权限来修复代码

Ubuntu tk.h在/usr/include中查找tcl.h,但tcl.h在/usr/include/tcl中。我不知道';我没有写入tk.h权限来修复代码,ubuntu,gcc,compiler-errors,tcl,tk,Ubuntu,Gcc,Compiler Errors,Tcl,Tk,我在macOS BigSur上通过VMWare使用Ubuntu20.04.2 LTS。我已经安装了tcl、tcl-dev、tk和tk-dev的最新版本-版本8.6。我想为这个项目编译源代码。源代码来自2016年,位于。编译失败[下面详细说明错误消息],可能是因为源代码依赖于tcl8.5而不是最新版本。安装这些软件包的8.5版可以解决这个问题吗 为了使GUI工作,在项目Makefile中,我需要分配一个变量[我已经完成了]并更新两个变量,以便gcc可以找到相关的库[libtcl.so和libtk.

我在macOS BigSur上通过VMWare使用Ubuntu20.04.2 LTS。我已经安装了tcl、tcl-dev、tk和tk-dev的最新版本-版本8.6。我想为这个项目编译源代码。源代码来自2016年,位于。编译失败[下面详细说明错误消息],可能是因为源代码依赖于tcl8.5而不是最新版本。安装这些软件包的8.5版可以解决这个问题吗

为了使GUI工作,在项目Makefile中,我需要分配一个变量[我已经完成了]并更新两个变量,以便gcc可以找到相关的库[libtcl.so和libtk.so]和头文件[tcl.h和tk.h]

# ******* variable 1 **********

# Assigning GUIMODE=-DHAS_GUI causes the necessary GUI support code in the simulator sources to be included.
GUIMODE=-DHAS_GUI

# ******* variable 2 **********

# Modify the following line so that gcc can find the libtcl.so and
# libtk.so libraries on your system. You may need to use the -L option
# to tell gcc which directory to look in. Comment this out if you
# don't have Tcl/Tk.

# TKLIBS variable tells gcc where to look for the libtcl.so and libtk.so libraries.
# TKLIBS=-L/usr/lib -ltk -ltcl

# ******* variable 3 **********

# Modify the following line so that gcc can find the tcl.h and tk.h
# header files on your system. Comment this out if you don't have
# Tcl/Tk.

# TKINC variable tells gcc where to find the tcl.h and tk.h header files.
# TKINC=-isystem /usr/include/tcl8.5

##################################################
# You shouldn't need to modify anything below here
##################################################

# Use this rule (make all) to build the Y86-64 tools. The variables you've
# assigned to GUIMODE, TKLIBS, and TKINC will override the values that
# are currently assigned in seq/Makefile and pipe/Makefile.
all:
        (cd misc; make all)
        (cd pipe; make all GUIMODE=$(GUIMODE) TKLIBS="$(TKLIBS)" TKINC="$(TKINC)")
        (cd seq; make all GUIMODE=$(GUIMODE) TKLIBS="$(TKLIBS)" TKINC="$(TKINC)")
        (cd y86-code; make all)

clean:
        rm -f *~ core
        (cd misc; make clean)
        (cd pipe; make clean)
        (cd seq; make clean)
        (cd y86-code; make clean)
        (cd ptest; make clean)
基于

$ locate libtcl.so
/usr/lib/x86_64-linux-gnu/libtcl.so

$ locate libtk.so
/usr/lib/x86_64-linux-gnu/libtk.so
我将TKLIBS更新为

TKLIBS=-L/usr/lib/x86_64-linux-gnu -ltk -ltcl
tcl.h和tk.h头文件位于:

$ locate tcl.h
/usr/include/tcl8.6/tcl.h
/usr/include/tcl8.6/tcl-private/generic/tcl.h

$ locate tk.h
/usr/include/tcl8.6/tk.h
/usr/include/tcl8.6/tk-private/generic/tk.h
/And many other folders, but only these two locations also have tcl.h
当我将TKINC更新为

TKINC=-isystem /usr/include/tcl8.6
我得到以下错误

az@ubuntu:~/Desktop/archlab-handout/sim$ make clean; make
rm -f *~ core
(cd misc; make clean)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/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]: Leaving directory '/home/az/Desktop/archlab-handout/sim/misc'
(cd pipe; make clean)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/sim/pipe'
rm -f psim pipe-*.c *.o *.exe *~ 
make[1]: Leaving directory '/home/az/Desktop/archlab-handout/sim/pipe'
(cd seq; make clean)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/sim/seq'
rm -f ssim ssim+ seq*-*.c *.o *~ *.exe *.yo *.ys
make[1]: Leaving directory '/home/az/Desktop/archlab-handout/sim/seq'
(cd y86-code; make clean)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/sim/y86-code'
rm -f *.o *.yis *~ *.yo *.pipe *.seq *.seq+ core
make[1]: Leaving directory '/home/az/Desktop/archlab-handout/sim/y86-code'
(cd ptest; make clean)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/sim/ptest'
rm -f *.o *~ *.yo *.ys
make[1]: Leaving directory '/home/az/Desktop/archlab-handout/sim/ptest'
(cd misc; make all)
make[1]: Entering directory '/home/az/Desktop/archlab-handout/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]: Leaving directory '/home/az/Desktop/archlab-handout/sim/misc'
(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/x86_64-linux-gnu -ltk -ltcl" TKINC="-isystem /usr/include/tcl8.6")
make[1]: Entering directory '/home/az/Desktop/archlab-handout/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 -isystem /usr/include/tcl8.6 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
    ../misc/isa.c -L/usr/lib/x86_64-linux-gnu -ltk -ltcl -lm
psim.c: In function ‘simResetCmd’:
psim.c:853:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  853 |  interp->result = "No arguments allowed";
      |        ^~
psim.c:861:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  861 |     interp->result = stat_name(STAT_AOK);
      |           ^~
psim.c: In function ‘simLoadCodeCmd’:
psim.c:872:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  872 |  interp->result = "One argument required";
      |        ^~
psim.c:878:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  878 |  interp->result = tcl_msg;
      |        ^~
psim.c:885:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  885 |     interp->result = tcl_msg;
      |           ^~
psim.c: In function ‘simLoadDataCmd’:
psim.c:895:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  895 |     interp->result = "Not implemented";
      |           ^~
psim.c:901:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  901 |  interp->result = "One argument required";
      |        ^~
psim.c:907:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  907 |  interp->result = tcl_msg;
      |        ^~
psim.c:911:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  911 |     interp->result = tcl_msg;
      |           ^~
psim.c: In function ‘simRunCmd’:
psim.c:925:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  925 |  interp->result = "At most one argument allowed";
      |        ^~
psim.c:932:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  932 |  interp->result = tcl_msg;
      |        ^~
psim.c:936:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  936 |     interp->result = stat_name(status);
      |           ^~
psim.c: In function ‘simModeCmd’:
psim.c:945:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  945 |  interp->result = "One argument required";
      |        ^~
psim.c:948:11: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  948 |     interp->result = argv[1];
      |           ^~
psim.c:957:8: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  957 |  interp->result = tcl_msg;
      |        ^~
psim.c: In function ‘signal_register_update’:
psim.c:994:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
  994 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘create_memory_display’:
psim.c:1005:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1005 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c:1020:60: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1020 |      fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                            ^~
psim.c: In function ‘set_memory’:
psim.c:1055:60: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1055 |      fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                            ^~
psim.c: In function ‘show_cc’:
psim.c:1069:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1069 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘show_stat’:
psim.c:1081:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1081 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘show_cpi’:
psim.c:1096:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1096 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘signal_sources’:
psim.c:1110:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1110 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘signal_register_clear’:
psim.c:1120:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1120 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘report_line’:
psim.c:1134:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1134 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘report_pc’:
psim.c:1190:56: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1190 |  fprintf(stderr, "Error Message was '%s'\n", sim_interp->result);
      |                                                        ^~
psim.c: In function ‘report_state’:
psim.c:1204:58: error: ‘Tcl_Interp’ {aka ‘struct Tcl_Interp’} has no member named ‘result’
 1204 |  fprintf(stderr, "\tError Message was '%s'\n", sim_interp->result);
      |                                                          ^~
make[1]: *** [Makefile:44: psim] Error 1
make[1]: Leaving directory '/home/az/Desktop/archlab-handout/sim/pipe'
make: *** [Makefile:30: all] Error 2
这可能是由于不同的tcl/tk版本造成的吗?我想知道8.5版是否会像Makefile中TKINC变量的默认值所暗示的那样有所帮助

如何安装版本8.5并确保gcc使用该版本


谢谢。

直接访问Tcl\u Interp结构已经很久了。鉴于这是一个单一源文件(psim.c),您可能希望对其进行修补以正确使用:

  • ,例如: 更改
    interp->result=“不允许参数”
    to
    Tcl_SetResult(interp,“不允许参数”,Tcl_STATIC)
  • ,例如: 更改
    fprintf(标准,“错误消息为“%s”\n”,模拟交互->结果)
    fprintf(stderr,“错误消息为“%s”\n”,Tcl_GetStringResult(sim_interp))
这是向后兼容的


不推荐,但可行:设置宏

#define USE_INTERP_RESULT

另请参见。

现在强烈反对访问该结构的内部构件。即使在8.5版本中,这也是一种糟糕的做法,事实上,自从20多年前8.0发布以来,这并不是一种推荐的做法。我猜有些人就是不经常更新他们的代码!请注意,设置
USE\u INTERP\u RESULT
在很大程度上是一种“Aaargh!我现在需要构建此代码!”的变通方法,而不是人们期望得到支持的方法;尤其是9.0发布后,它根本没有机会在9.0中工作。@Calvin先生。我现在已经用您概述的补丁更新了psim.c。现在编译不会引起我的原始消息中提到的任何错误。但是,有些错误仍然存在,我怀疑这些错误与tcl无关,但我的变量TKLIBS在其中查找libtcl.so和libtk.so库。错误出现在以下注释之后:“未定义对'matherr'的引用”是的,
matherr
是现代glibc中不再可用的符号。例如,请参见从psim.c和ssim.c中删除的对matherr的引用。编译完成时没有出现错误,初步测试表明GUI模拟器工作正常。
#define USE_INTERP_RESULT