在Mac下使用nsf的”gothic”(Tcl/Tk Go绑定)库时遇到问题。

huangapple go评论110阅读模式
英文:

Pb using nsf's "gothic" (tcl/tk go binding) library under Mac

问题

我已经在Linux下使用nsf的"gothic"(Tcl/Tk的Go绑定库)一段时间了:它运行得非常好,非常方便地为Go应用程序添加了一个基于Tcl/Tk的图形界面(类似于Tkinter对Python的作用)。

然而,在Mac下安装它时我遇到了一些问题。

为了解决这个问题,我对我的Mac开发环境进行了以下修改:

  • 安装了最新版本的Xcode。

  • 完全删除了"port"(用于Mac的Linux工具的端口)并重新安装了最新版本。

  • 升级到了最新稳定版本的Go。

现在至少我可以在Mac下安装"gothic",并且它可以编译而不报错。

我不得不对interpreter.go文件进行以下更改,以便头部指令指向正确的库位置:

#cgo !tcl85 LDFLAGS: -L/opt/local/lib
#cgo !tcl85 LDFLAGS: -ltcl8.6 -ltk8.6
#cgo !tcl85 CFLAGS:  -I/opt/local/include/tcl8.6
#cgo darwin tcl85 CFLAGS: -I/opt/local/include
#cgo darwin tcl85 CFLAGS: -I/opt/local/include/tcl8.6

而不是原来的:

#cgo !tcl85 LDFLAGS: -ltcl8.6 -ltk8.6
#cgo !tcl85 CFLAGS: -I/usr/include/tcl8.6
#cgo tcl85 LDFLAGS: -ltcl8.5 -ltk8.5
#cgo tcl85 CFLAGS: -I/usr/include/tcl8.5
#cgo darwin tcl85 CFLAGS: -I/opt/X11/include

这样就可以指向正确的库了。

目前的情况是,示例可以编译,没有任何警告或错误信息。

问题是生成的可执行文件只有在随机的情况下才能正确运行,大部分时间只是"挂起"(显示一个空白矩形,应该是界面的位置),程序的执行被阻塞。

在nsf的代码中,最后执行的语句(当可执行文件被卡住时)显然是对Tk_Mainloop()的调用。

这是我在尝试找出问题所在时所做的进展。

所以显然,这不是Go到Tcl绑定的问题。

在这种情况下,Tcl和Tk之间的"连接"有时候工作,有时候不工作(而在Linux下完全正常)。

有没有人在Mac上使用"gothic"取得更多成功(或者在Mac上使用tcl/tk绑定的经验更丰富)?

如果是的,非常感谢能够提供一些关于如何继续的帮助。

谢谢!

英文:

I have been using nsf's "gothic" (tcl/tk go binding) libary under Linux for a while now : it works very well and is very convenient for adding a tcl/tck-based graphical interface to a Go application (more or less what Tkinter is to Python).

https://github.com/nsf/gothic

However, I experienced a few problems installing it under Mac.

In an attempt to solve that problem, I made the following modifications to my Mac development environment:

  • Installed the latest version of Xcode.

  • Removed "port" (port of the Linux tools for Mac) entirely and installed it from scratch to the latest version.

  • Upgraded to the latest stable version of Go.

Now at least I can install "gothic" under Mac and it compiles without complaining.

I had to make the following changes to the interpreter.go file, so that the header directives point to the correct library location:

#cgo !tcl85 LDFLAGS: -L/opt/local/lib
#cgo !tcl85 LDFLAGS: -ltcl8.6 -ltk8.6
#cgo !tcl85 CFLAGS:  -I/opt/local/include/tcl8.6
#cgo darwin tcl85 CFLAGS: -I/opt/local/include
#cgo darwin tcl85 CFLAGS: -I/opt/local/include/tcl8.6

instead of the original:

#cgo !tcl85 LDFLAGS: -ltcl8.6 -ltk8.6
#cgo !tcl85 CFLAGS: -I/usr/include/tcl8.6
#cgo tcl85 LDFLAGS: -ltcl8.5 -ltk8.5
#cgo tcl85 CFLAGS: -I/usr/include/tcl8.5
#cgo darwin tcl85 CFLAGS: -I/opt/X11/include

So that is points to the correct libraries.

The current situation is that the examples do compile, without any warnings or error messages.

The problem is that the resulting executables only run correctly randomly, form time to time, but most of the time just "hangs" (displays an empty white rectangle where the interface should be) the execution of the program blocks.

In nsf's code the last statement which gets executed apparently (when the executable gets stuck) is the call to Tk_Mainloop().

This is as far as I have come in trying to figure out what is going wrong.

So obviously, it is not a Go (golang) to Tcl binding problem.

It looks as if the "connection" between Tcl and Tk sometimes works and sometimes not in that context (whereas it works perfectly under Linux).

Has anybody had more success in using "gothic" on a mac (or possibly more experience with using tcl/tk bindings under mac) ?

If yes, would be very grateful for some help on how to proceed.

Thanks,

答案1

得分: 0

与此同时已安装:

  • Yosemite(Mac OS X 10.10.1)
  • 最新版本的“Port”(https://www.macports.org/)
  • XQuartz 2.7.7,现在它可以工作了

Nsf.s Gothic(tcl/tk到Golang绑定)库现在在Mac上似乎可以正常工作!

因此,关于问题与(晚期)X11.app的实现有关的假设是正确的!

Serge

英文:

in the meantime installed :

Nsf.s gothic (tcl/tk to Golang binding) library appers to work correctly on Mac now !

So the assumption that the problem was linked to the (late) implementation of X11.app was correct !

Serge

huangapple
  • 本文由 发表于 2014年10月9日 21:01:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/26279098.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定