How to compile SRILM on Ubuntu

EDIT: This is my original post, but the comments have newer and better instructions.

I always encounter problems when compiling SRILM on Ubuntu.  Assuming the basic SRILM dependencies are installed on your system (see the Prerequisites), this works for SRILM 1.5.11 on Ubuntu 9.04 (Jaunty) and 10.04 (Lucid):

  1. Install tcsh if not already installed
  2. Install all the TCL developer libraries: tcl8.4-dev, tcl-dev, tcl-lib, tclx8.4, tclx8.4-dev.  This step may not be necessary, let me know what works for you.
  3. Uncomment the “SRILM =” line in the top level Makefile and replace the existing path with the absolute path of the SRILM top-level directory on your system (where the Makefile resides)
  4. Start the tcsh shell
  5. Type “make NO_TCL=X MACHINE_TYPE=i686-gcc4 World > & make.log.txt” to begin the build and capture stderr and stdout in a file
  6. If you can run “./bin/i686-gcc4/ngram-count -help“, the build was probably a success

Please add simplifications to this recipe or extensions to other versions of Ubuntu in the comments.

Tags: , ,

14 Responses to “How to compile SRILM on Ubuntu”

  1. Jonas Says:

    Thank you so much for the instructions, they really helped me a lot.

    A few notes:

    It is necessary to install gawk (Ubuntu by default uses mawk) otherwise ALL tests will fail!

    It is enough to just install tcl-dev (at least in Ubuntu 10.10). All other necessary Tcl libraries will be installed that way. Why one must install the tcl-dev when compiling without Tcl I don’t understand.

    For me it wasn’t necessary to start tcsh. Using bash worked just as well.

    It is possible to set machine type to MACHINE_TYPE=i686-ubuntu. I don’t know if that brings any advantages though

    So here is my simplified version:

    Install the following packages:
    build-essential csh tcl-dev gawk

    Uncomment the “SRILM =” line in the Makefile and set it to your directroy

    make NO_TCL=1 MACHINE_TYPE=i686-ubuntu World

    To run the tests type do the following:

    export PATH=$PATH:/path_to_srilm_dir/bin/i686-ubuntu:/path_to_srilm_dir/bin
    where path_to_srilm_dir is replaced with the actual SRILM directory

    and then run:
    make test

    I tested that it works on a fresh Ubuntu 10.10 installation.

  2. Yatzi Says:

    I’m still getting the following errors! :

    ubuntu:~/MOSES/tools/srilm> make NO_TCL=1 MACHINE_TYPE=i686-ubuntu World
    mkdir include lib bin
    mkdir: cannot create directory `include’: File exists
    mkdir: cannot create directory `lib’: File exists
    mkdir: cannot create directory `bin’: File exists
    make: [dirs] Error 1 (ignored)
    make init
    make[1]: Entering directory `/home/anakin/MOSES/tools/srilm’
    for subdir in misc dstruct lm flm lattice utils; do \
    (cd $subir/srcc; make SRILM=/home/anakin/MOSES/tools/srilm MACHINE_TYPE=i686-ubuntu OPTION= MAKE_PIC= init) || exit 1; \
    /bin/sh: Syntax error: end of file unexpected (expecting “done”)
    make[1]: *** [init] Error 2
    make[1]: Leaving directory `/home/anakin/MOSES/tools/srilm’
    make: *** [World] Error 2

    • romanows Says:

      It looks like the “Syntax error” is referencing the fact that the script has “dnee” where there should be the word “done”? Try correcting this in the script/makefile and see if that helps.

      I’ll be playing around with new Ubuntu installs late next week, so I’ll try compiling SRILM again and report back.

  3. romanows Says:

    I finally upgraded to Ubuntu 11.04 (Natty Narwhal) and compiled SRILM 1.5.12. The instructions by Jonas in an above comment are fantastic.

    I had to use the “MACHINE_TYPE=i686-gcc4” flag because make complained about “gnu/stubs-64.h” when I used the “MACHINE_TYPE=i686-ubuntu” flag. I have a 32-bit processor/OS, so perhaps if you have a 64-bit OS the i686-ubuntu flag would work well or better?

    Thanks again, Jonas!

  4. Jonas Says:

    I’m glad it helped

  5. regak Says:

    (In Ubuntu 10.10)
    Yap…romanows is absolutely right. I have a 32-bit OS so i had to change to the previous flag(i686-gcc4). But otherwise Jonas instrcutions are just fine.

  6. Dhi Says:

    everything wroked as per Jonas except this error

    make init
    make[1]: execvp: /home/ds/Project/srilm: Permission denied

    …always encountering it . help

    • romanows Says:

      Maybe the file permissions prevent you from writing to one of the files in the srilm directory?

      Try running “chmod -R u+wr srilm” from the “Project” directory. That should recursively set permissions on all files in srilm to allow reading and writing.

      • Dhi Says:

        Done that, but still the problem persists

        ds@Halo:~/Project/srilm$ make test
        make: execvp: /home/ds/Project/srilm: Permission denied

        • romanows Says:

          Sorry, for the lag in replying. I don’t know what is going on with your install, unfortunately. There is an SRILM mailing list, I believe, and they could probably be of more help if you were able to post the full output from the makefile.

        • Dhi Says:

          Done, reinstalled it on upgraded Ubuntu 11.10. Use MACHINE_TYPE=i686-gcc4 instead of MACHINE_TYPE=i686-ubuntu(this gave errors in 11.10).

  7. Andrey Says:

    If you’re running a 64-bit machine and encounter “fatal error: bits/predefs.h: No such file or directory”, you might need to install libc6-dev-i386

  8. Abdul Says:

    make init
    make[1]: execvp: /home/ds/Project/srilm: Permission denied

    I figured out that above error was occuring in my case under ubuntu 12.04 due to files being upacked into a folder named srilm. After unpacking files into a folder named srilmx.x.x where x.x.x is version number it worked fine.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: