Update: Installing Molden on 64bit Debian based GNU/Linux Systems

Quite some time ago, I have posted a script that attempts to install Molden. This has become a very popular post but when I read the script again recently, I felt a strong obligation to post a much cleaner way to do things. The following instructions should work for any Debian based GNU/Linux distribution. This includes Ubuntu, but – while in the past, I have been using Ubuntu myself – I cannot recommend it any longer because it does a poor job in respecting your freedom. If you like Ubuntu‘s look & feel but value your freedom, you might want to give Trisquel a try. Anyway, this is about getting Molden to work.

First you will need to install a number of dependencies. I prefer gfortran but you may pick another Fortran compiler as well.

$ sudo apt-get install build-essential gfortran libX11-6 libX11-dev libgl1-mesa-dev libgl1-mesa-glx libglu1-mesa-dev libxmu-dev makedepend xutils-dev mesa-common-dev

Now download and extract the lastest Molden tarball.

$ wget ftp://ftp.cmbi.ru.nl/pub/molgraph/molden/molden5.0.tar.gz
$ tar -xf molden5.0.tar.gz
$ cd molden5.0

In the makefile, one of the first lines assigns the variable FC the name of the Fortran compiler to use. If using gfortran, it should read

FC = gfortran

If you have a 64bit operating system, comment / uncomment the following lines like this further down in the makefile

#LIBS = -L/usr/X11R6/lib -lX11 -lm
LIBS = -L/usr/X11R6/lib64 -lX11 -lm

or vice versa for 32bit systems (which should be the default anyway).

Now build Molden. I get some ugly compiler warnings here, but they don’t seem to affect the usability of the product.

$ make

There is no install target so you’ll have to manually

$ sudo install -t /usr/local/bin -m 755 molden gmolden

This should have been all. The build directory can now be removed.



  1. Fred
    Posted 2013-03-14 at 10:32 | Permalink | Reply

    Thanks a lot.
    To get “makedepend”, I had to install “xutils-dev” dependency

    • mklammler
      Posted 2013-03-14 at 10:50 | Permalink | Reply

      thanks, updated post

      • Fred
        Posted 2014-02-05 at 11:00 | Permalink

        To compile MOLDEN 5.07 on UBUNTU 12.04 LTS (updated on Feb 5, 2014), I had to install “libgl1-mesa-dri” instead of “libgl1-mesa-glx” dependency

  2. Gary
    Posted 2013-05-12 at 17:53 | Permalink | Reply

    Thank You, I have been changing OS ( from MInt, to Mageia, to Debian) for this.

  3. m
    Posted 2013-07-09 at 23:49 | Permalink | Reply

    hey many thanks!! works like a charm.

  4. B. Cruz
    Posted 2013-11-21 at 21:39 | Permalink | Reply

    Thanks man! very helpful!

  5. Karl I.
    Posted 2014-02-05 at 15:56 | Permalink | Reply

    Thank you! It worked without problem on my fresh Ubuntu 12.04 LTS installation.

  6. naty
    Posted 2014-07-04 at 14:57 | Permalink | Reply

    thanks its working perfectly on ubuntu 14.04

  7. Posted 2015-04-02 at 16:11 | Permalink | Reply

    It seems that libx11-6 is a dependency for libx11-dev, so there is no need to install both explicity. Besides, libgl1-mesa-dev has both libx11-dev and libgl1-mesa-glx as dependencies. And libglu1-mesa-dev has libgl1-mesa-dev as dependendy.

    So, in order to install molden on Ubuntu, I had to install gfortran, libglu1-mesa-dev and xutils-dev (because of makedepend). Be aware that I’ve used aptitude.

    I didn’t change anything in the makefile for the current version (5.2.2, ftp://ftp.cmbi.ru.nl/pub/molgraph/molden/molden5.2.2.tar.gz). And since I’ve installed it on /opt/molden/5.2.2, I did:

    sudo install -t /opt/molden/5.2.2 -m 755 molden gmolden ambfor/ambfor surf/surf

    And that was it.

  8. Lasan
    Posted 2015-06-04 at 23:36 | Permalink | Reply

    Thank you very much. It helped.

  9. Jambar
    Posted 2016-02-03 at 21:26 | Permalink | Reply

    Thank you

  10. dani
    Posted 2016-03-23 at 17:10 | Permalink | Reply

    Thank you very much for the post! However Im having a problem with the last step- it says

    cannot stat ‘gmolden’: No such file or directory

    I can load molden, but I would really need the improvements in gmolden. Do you know how I could fix it?

    Thank you very much

    • Posted 2016-03-23 at 21:16 | Permalink | Reply

      I’m sorry, I’m not using the Ubuntu (or even Debian) environment myself any more so I cannot try reproducing your problem. Did you get any errors during the build process? Try `make gmolden` and carefully look at the output it produces to see at what point it fails. Maybe this can hint you into the right direction. You can also run `make -n gmolden` to only have it print what it *would* do without actually doing anything.

      • dani
        Posted 2016-03-24 at 10:08 | Permalink

        I did get some errors during the building, but I did not pay much attention (my fault) because I read that you also got them but did not compromise the functions of the program.
        When doing ‘make gmolden’ after a bunch of lines I get this

        collect2: error: ld returned 1 exit status
        makefile:262: recipe for target ‘gmolden’ failed
        make: *** [gmolden] Error 1

        I don’t really know what that means.
        I’ve noticed that in the makefile it says this:

        # Linux version
        # Make sure the Xwindow include files are installed in an rpm package
        # called libX11-devel-*
        # For gmolden you also need the OpenGL include files contained in the
        # rpm packages mesa-libGL-devel* and mesa-libGLU-devel-*

        Would it be a matter of installing these libraries? If so, how can I get them and where should I locate them?

        Thank you very much!!

    • Posted 2016-03-24 at 15:51 | Permalink | Reply

      I got some (many) compiler *warnings*, not *errors*. It seems in fact that you are missing a GUI library that gmolden wants to link with. There should be an earlier error message that gives more details about the missing symbols which might help you locate the missing library. (Search the web for the symbols it mentions.) Also see the comments of other people above about these libraries. You can search for packages in Ubuntu via the graphical package manager or online at http://packages.ubuntu.com/ . After you have installed the packages providing the libraries, try building again. As long as the packages don’t conflict which each other (your package manager will tell you this), there is no harm done by installing more packages than actually needed for the build (except for unnecessary usage of disk space, of course) so you may install them liberally in case of doubt.

      • dani
        Posted 2016-03-24 at 16:57 | Permalink

        Thank you again! With respect to the error that I posted before

        makefile:262: recipe for target ‘gmolden’ failed

        If I look at the makefile, in line 262 it says

        gmolden: $(OBJS) mpdum.o xwingl.o
        $(LDR) -o gmolden $(OBJS) mpdum.o xwingl.o $(LIBSG)

        Does that give any hint?

        I am trying to download the libraries but I am not sure how to do it. I found this website with the libraries


        but I have never done it before. Is there any relatively easy way out of this or with each problem that I face I will be more lost? 🙂

        Thank you very much

    • Posted 2016-03-24 at 18:33 | Permalink | Reply

      Look for the line in the `Makefile` that sets the `LIBSG` variable. It should contain linker flags of the kind `-lfoo -lbar …`. Then check for each listed library (in this case: libfoo and libbar) what package provides them, using the search function of your package manager and install the respective packages. There should be no need to download and install any packages manually.

        Posted 2016-03-31 at 14:31 | Permalink

        Hi again. Thanks for the indications. It turns out that my machine is missing the Nvidia drivers, that is why I was getting constantly strange messages. Ill try to install it and proceed how you suggested.


  11. Tux
    Posted 2016-05-11 at 16:46 | Permalink | Reply

    thank you so much so helpfull !!!!

  12. Mff22
    Posted 2016-09-24 at 05:45 | Permalink | Reply

    I made a .sh file that installs molden 5.7 almost automatically (it asks for the user password in the beginning and a “y” near of the end), but it does not change anything inside of the makefile, just update everything needed and compile it, it worked in my ubuntu 16. If there is anyone interested, i can post the code here if is possible and allowed.

  13. Posted 2017-04-09 at 00:18 | Permalink | Reply

    Awesome blog! Do you have any helpful hints for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you propose starting with a free platform like WordPress or go for a paid option? There are so
    many choices out there that I’m completely confused ..
    Any tips? Thank you!

One Trackback

  1. […] on this blog, but the script provided below is very ugly. Please follow the instructions given in this update […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s