CERN Accelerating science

You are here

Installing Molflow on Mac

To install Molflow on a Mac, you have to go through the following steps:

  • Download and extract Molflow
  • Install Homebrew
  • Get four packages
  • Make Molflow executable
  • Run Molflow

If you just want the instrutions, scroll down, otherwise keep reading

Why does it have to be so difficult?

As a Mac user you're probably used to either the App Store, or ready-built dmg packages where you drag a colorful icon to the Applications folder and just run it. This works with most applications either developed exclusively for Mac, or maintained by larger teams that can afford the effort to develop for the Apple ecosystem.

Molflow runs on Windows, Linux and Mac using exactly the same, standard C++ code. The idea is to ignore built-in package managers, app stores and update mechanisms, and publish exactly the same program for all platforms. That way I don't need to register an Apple developer account, I don't need verification by Apple or digital signatures, and I can provide my own updater mechanism that downloads and installs new versions automatically.

What is Homebrew?

The good news is that Mac OS is a fully Unix-compliant operating system, so in theory anything running on Linux can be ported to it.

The bad news is that many standard tools, like a C compiler, package manager, X11 renderer and other linux stuff are missing from it, because Apple decided that you don't really need them (just use the App Store).

Now, the open source community fixed this by writing Homebrew, a package manager that installs, as the website says, "stuff you need that Apple didn't". Don't be scared of it, it doesn't change the way your Mac works, just downloads and extracts stuff in your /usr/local folder, and it can be uninstalled completely. We'll use it to get some packages that Molflow uses.

What packages does Molflow need?

  • The SDL2 framework that creates an OpenGL context for the main window, captures mouse and keyboard events and handles tasks like copying and pasting from the clipboard
  • LibPNG to load icons and fonts, and to save screenshots in PNG format
  • The GNU Scientific library to generate random numbers
  • The C standard library, included in the GCC package to run modern applicaitons written in C++17

Why didn't you just include these packages?

In short, because it would do more harm than good.

See, in Windows, packages can be statically linked (included in the exe file) or dynamically linked (included in a dll file). Windows very rarely makes breaking changes, the last time the binaries were changed was the transition from XP to Vista in 2007. On the other hand, when Molflow became 64-bit in 2014 all libraries had to be changed.

In the unix/linux world, things are different. Mac OS makes major upgrades every year, for example in Mac OS Mojave OpenGL is declared deprecated, and Mac OS 10.15 is expected to drop 32-bit support whatsoever. In the Linux world, many flavors of Linux are not compatible with each other. To save developers from chaos, maintainers of these distributions provide most packages for each version of the operating system, and programs such as Molflow simply reference them. It provides compatibility with future versions, but - as opposed to Windows where you just put some DLLs in the orgram folder - you have to get these packages yourself.

What does it mean to make Molflow executable?

In Windows you can double-click and run exe files.

In Linux and Mac OS, any file, regardless of extension, can be executable. Now this could be a security concern, since one could send you a safe-looking file called bunny.jpg but it would in reality erase all your files or launch a never-ending Monte Carlo simulation :) Therefore you have to explicitly mark files to execute after downloading. You need to do it only once for Molflow (except when the updater gets you a newer version).

Here is what you need to do:

In the instructions below, ignore line breaks, all Terminal commands are to be pasted in a single line.

  • Download the latest Mac version in ZIP format from this site and extract it somewhere. In this example I'll extract it to the Desktop.
  • Open a Terminal and navigate to where Molflow is.
    (Press Command+SPACE to open spotlight, type terminal and press ENTER). Type cd Desktop/molflow_mac_2.7.0 to change to that folder. You can use the TAB key to autocomplete directory names)
    Screen Shot 2018-10-09 at 9.55.15 AM.png
  • Paste and run the following command to install Homebrew:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    You'll have to type your password and it will take 15-20 seconds to install. In the Mac terminal you can paste with Command+V
  • Paste and run the following to install packages:
    brew install sdl2 libpng gsl gcc
    Note: As of May 2019, Homebrew will install gcc version 9. Molflow 2.7.7 and earlier were compiled with gcc8, so you'll need a later Molflow version. 
  • Make Molflow and its 7-zip compressor tools executable:
    chmod +x molflow 7za compress
  • That's it! Launch Molflow by typing ./molflow in the terminal, or by opening the Molflow folder in Finder and double-clicking on the molflow file which by now is executable.

If Molflow is opening with a black window, move the window's position to restore it. It's unclear whether it's a bug in Molflow, the SDL2 framework or the OpenGL implementation is Mac OS Mojave, I'll investigate.
Update 2019-01-25: This was a bug in the SDL2 framework, fixed in version 2.0.9, fix included in Molflow 2.7.3 and later.

Screen Shot 2018-10-09 at 9.49.12 AM.pngScreen Shot 2018-10-09 at 9.49.20 AM.png

This has been tested to work on a Macbook Pro running Mac OS Mojave. Report if you run into problems!

How to uninstall everything:

  • Delete Molflow's folder
  • Uninstall homebrew and its packages by pasting the ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" command  to the terminal.

 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer