In this article I am going to teach you how to compile Astrolog on macOS with X11 Graphics. This is absolutely a geeky post 🤓, and it is addressed specifically to people interested in having the Astrolog software running on macOS with graphics features on. As you might know the version available on the official website doesn’t support graphics so what you need to do is to compile it from scratch with the X Windows System (X11) enabled.
Installing X11 on macOS
At the time of this article the last version available of Astrolog is the 6.50, click on this link to download it. If the link doesn’t work most likely a new version has been released, so visit astrolog.org and get it.
We are going to compile+link the code from the terminal, but first you need to download and install X11 libraries for macOS, available at XQuartz.org. X11 is no longer pre-installed on macOS and you need to manually install it. This is a very quick and easy thing to do, but if you are having any problem please follow the tutorial below.
Now you should have everything you need to compile the source code and link the objects. If you are not a computer programmer you can follow the instructions step by step—you should make it through. But please note you still need to be somewhat familiar with the terminal to do that.
We are going to compile the source code now. If you open the makefile in the /ast65src source code folder you are going to find this comment:
# This Makefile is included only for convenience. One could easily compile # Astrolog on a Unix system by hand with the command: # % cc -c -O -Wno-write-strings *.cpp; cc -o astrolog *.o -lm -lX11 # Generally, all that needs to be done to compile once astrolog.h has been # edited, is compile each source file, and link them together with the math # library, and if applicable, the main X library.
We are going to compile it by hand, we are not going to use the makefile. However, the command like provided is missing the reference to include the X11 Library you have just installed. This means that if you try to launch that command you are going to get a bunch of errors referring to X11 libraries missing.
So try to run the command line below instead. Before doing that please be sure that your X11 libraries have been installed under /usr/X11/. You can open the /usr folder with the “go to” command in the finder by pressing ⌘⇧G.
Open the terminal, go to the /ast65src folder and launch this command:
cc -I /usr/X11/include -c -O -Wno-write-strings *.cpp; cc -o astrolog *.o -lm -lX11 -v
If this is your first time launching the compiler you should get a message box, asking you to install the developer command line tools. Press OK and finish the installation process. Once finished, launch the command line again, you should get two things:
- A bunch of object files (with .o extension) in the /ast65src folder
- An error thrown by the linker (red arrow below) that we are going to solve in the next step:
We are almost done, we just need to link the .o objects together and obtain the executable file. The errors given by the linker are caused again by a wrong reference to X11 libraries. The linker is looking for them in /usr/local/lib, but they are in /usr/X11/lib instead. We can tell the linker to look for them under the correct folder replacing the wrong reference in the -L option.
If you are running macOS 10.14 Simply copy and paste the command below, it should work:
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o *.o -lm -lX11 -L/usr/X11/lib -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a
If it doesn’t work copy and paste the code highlighted in the green box (see picture above), you should get it from the output of the previous step. Your command line should be somewhat different (most likely CommandLineTools references and macOS version are going to slightly change), but all you need to do is replacing -L/usr/local/lib with -L/usr/X11/lib.
Once you run the modified command line, nothing happens. This is a good sign, it means it worked. The linker linked successfully the program! Now you can give it a try launching this spectacular command:
astrolog -Xn -XG