Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS support #1

Open
bnoordhuis opened this issue Jun 28, 2017 · 2 comments
Open

MacOS support #1

bnoordhuis opened this issue Jun 28, 2017 · 2 comments

Comments

@bnoordhuis
Copy link
Owner

Currently blocked on ABI compatibility issues between XQuartz (X server) and the Tcl/Tk shipped by Apple:

Tcl_Interp *tcl = /* ... */;
// Segfaults...
DefaultColormapOfScreen(
    XDefaultScreenOfDisplay(
        Tk_Display(Tk_MainWindow(tcl))));

Can possibly be overcome by using a third-party Tcl distro like ActiveTcl.

@bnoordhuis
Copy link
Owner Author

So I don't forget.

configure.ac patch:

diff --git a/configure.ac b/configure.ac
index d9c9303..6563294 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,17 +33,17 @@ AC_DEFINE(TKGATE_HOMEPAGE,  "https://github.com/bnoordhuis/tkgate",         [TkGate web
 #
 # Tcl/Tk version we will try to use (from most favored to least favored)
 #
-TKGATE_TCLTK_VERSIONS="8.5 8.4 8.3"
+TKGATE_TCLTK_VERSIONS="8.6"
 
 #
 # Directories to search for include files
 #
-TKGATE_INCDIRS="/usr/X11R6/include /usr/X11/include /pkgs/include /usr/local/include /usr/openwin/include /usr/X/include /usr/include /sw/include /opt/local/include"
+TKGATE_INCDIRS="/opt/X11/include /usr/local/opt/tcl-tk/include"
 
 #
 # Directories to search for library files
 #
-TKGATE_LIBDIRS="/usr/X11R6/lib /usr/X11/lib /pkgs/lib /usr/local/lib /usr/lib /sw/lib /opt/local/lib"
+TKGATE_LIBDIRS="/opt/X11/lib /usr/local/opt/tcl-tk/lib"
 
 #
 # Libraries we may need if available.

test program:

// cc -g -Wall -Wextra
// -I/opt/X11/include -I/usr/local/Cellar/tcl-tk/8.6.9/include t.c
// -L/opt/X11/lib -L/usr/local/Cellar/tcl-tk/8.6.9/lib
// -ltcl8.6 -ltk8.6 -lX11

#include <err.h>
#include <X11/Xlib.h>
#include <tcl.h>
#include <tk.h>

int
main(void)
{
        Tcl_Interp *tcl = Tcl_CreateInterp();

        if (TCL_ERROR == Tcl_Eval(tcl, "set tcl_library /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6"))
                errx(1, "Tcl_Eval: %s", Tcl_GetStringResult(tcl));

        if (TCL_ERROR == Tcl_EvalFile(tcl, "/usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/init.tcl"))
                errx(1, "Tcl_EvalFile: %s", Tcl_GetStringResult(tcl));

        if (TCL_ERROR == Tk_Init(tcl))
                errx(1, "Tk_Init: %s", Tcl_GetStringResult(tcl));

        Tk_Window w = Tk_MainWindow(tcl);
        Display *d = Tk_Display(w);
        Screen *s = XDefaultScreenOfDisplay(d);  // crash: d dangles
        Colormap c = XDefaultColormapOfScreen(s);
        (void) &c;

        return 0;
}

@bnoordhuis
Copy link
Owner Author

I've made some progress on this. Trying to use the tcl/tk from Apple or homebrew was a dead end. They're both using CoreGraphics, whereas tkgate is strictly X11 - i.e., completely incompatible.

Building tcl and tk from source (with the --with-x option in case of tk) and building and linking tkgate against that did work, now I just need to package it up into a simple recipe, probably a Makefile.

bnoordhuis added a commit that referenced this issue Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant