
On MacOS X, XQuartz enables you to use the X11 window system.
X11 Forwarding on Mac. X11 forwarding on Mac is just as easy. Download Quartz and install it as you would any other Mac package. Quartz is another instance of display management. Apple X11 for Mac, free and safe download. Apple X11 latest version: Launch hundreds of X11 programs on Mac OS X. X11 for Windows and Mac. X11 is a remote-display protocol used by Linux/Unix machines, including the Linux machines at Thayer. By running an X11 program (known as a server) on your computer, you can access graphical Linux programs remotely through an SSH client. In addition some.nix applications ported to macOS do not run natively under the.
Here we provide two ways to install XQuartz application. You could either install from official website or install with Homebrew. In general, we recommend you to use Homebrew to install and manage packages on MacOS X.
brew tap caskroom/cask. 2. Install XQuartz with command brew cask install xquartz.Open XQuartz application from the launchpad on your Mac to see if it is installed correctly. It will open an xterm window. If that does not work immediately, try restarting your computer.
Next, try running an X11 application on one of the CS50 Unix servers. Log into a CS50 Unix server and launch an X11 application, such as xclock or xemacs. For a little fun, try xeyes.
The -X option to ssh sets up X11 forwarding for ssh connections. That is, it sets up a secure tunnel between the program (like xclock) running on the server and the XQuartz application on your Mac; the program can create windows, buttons, menus, etc.; all the information flows through the ssh tunnel to XQuartz, which renders the windows on your Mac. It works with all CS50 Unix servers. xpdf will open a pdf viewer in X windows system on your local computer. Here’s an xpdf window.
Note
A warning may show up saying $Home/.Xauthority does not exist if it is your first time to use X11. The Xauthority file will be configured automatically at the first run. From then on, the warning should not appear.
Reference
If you need a GUI (graphical user interface), we recommend the gtk+ library, which is a popular UI toolkit for the X11 window system. There are two versions of gtk+ libraries: gtk+-2(version 2) and gtk+-3(version 3). gtk+-2 is still alive but we recommend the latest version, gtk+-3. Both versions are ready to use on our CS50 Unix servers, so you need to specify the version to work with at compile time.
The gtk-example.c example program, below, uses gtk+-3. It opens a window with a simple button, as shown below the code. Feel free to use!
Compiling with gtk+
Use the following command to compile gtk-example.c:
pkg-config --cflags gtk+-3.0 will produce a list of header paths you might use in your application and pkg-config --libs gtk+-3.0 will produce a list of library paths. (Notice the use of back-ticks for bash command substitution.) A more detailed explanation can be found in references below, which include a well-written tutorial.
Reference