How to build tk/tcl _tkinter on macOS
Maybe related to #3697, #3538 (closed)
Disclaimer: I know nothing about xcode, homebrew. I am trying to fix our packaging script so it can build _tkinter
, and cannot work out how CPython does it. This issue and PR seem relevant, but I don't see how they solve the problem. I have a M1 mini, running macOS 12.4 and xcode installed. I have a very minimal homebrew installed, but would prefer to use system libraries if possible.
This simple program (/tmp/test_tk.c
) fails to compile on macOS:
#include <tk.h>
int main(int argc, const char *argv[]){
return 0;
}
with the command line
cc -pthread -arch arm64 -DNDEBUG -O2 -fPIC -c /tmp/test_tk.c
It reports the error
In file included from /tmp/test_tk.c:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tk.h:86:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^~~~~~~~~~~~
1 error generated.
Now I see Xlib.h
in various places, among them /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h
, but how is the compiler meant to find it?
@mattbillenstein ideas?