How to Compile Astrolog on macOS with X11 Graphics

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.

Compile Astrolog on macOS: Chart Sphere animation example in Astrolog
Chart Sphere animation example in Astrolog

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.

What X11 is and how to install it on macOS

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.

Compiling Astrolog

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:

  1. A bunch of object files (with .o extension) in the /ast65src folder
  2. An error thrown by the linker (red arrow below) that we are going to solve in the next step:
Compile Astrolog on macOS: Compiler and linker output
Compiler and linker output

Linking Astrolog

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

Enjoy! 🙏

6 comments

  1. Hi,
    thank you for writing this easy-to-follow guide! Everything went exactly as you described it but, i encountered the following message, and I am unable to execute the program:

    Undefined symbols for architecture x86_64:
    “_main”, referenced from:
    implicit entry/start for main executable
    ld: symbol(s) not found for architecture x86_64

    I am using a MacBook Pro (MacBookPro9,2) Dual-Core Intel Core i5.

    I’d appreciate if you could offer any help with this. Thank you in advance!
    Jose

    • Hey Jose,
      try not to use my linking command with *.o and use the command you should find from the compilation output. Just remember to correct the X11 library reference. Also remember to delete all .o objects before starting..

  2. Thank you for compiling Astrolog for the Mac with interactive graphics, and for making this guide available! :) Would it be possible to make the precompiled Astrolog Mac binary available for download? That would allow Mac users to easily run the program without having to compile it themselves (which not every Mac user will be able to do, even with these quality instructions).

    • Hey Walter, that sounds great :)
      I didn’t want to publish the program without your permission, so I published this mini tutorial instead.
      I’m gonna make another post to download it, adding some instructions (you still need to install X11 for Mac).
      I am also going to include the bug fix you provided me for the rendering problems on the -V command.

      Thanks for reaching out

Leave a Comment

–––––––––––– OR ––––––––––––