Compiling EIGENSOFT on Ubuntu Januty

These are rough notes on how to compile Eigensoft 3 on Ubuntu Jaunty.

Update, Eigensoft 4 is available and should compile on more recent versions of Ubuntu:

Create a location to build the code:

Warning: /tmp is for temporary files, and any files & directories you create there will be remove upon some subsequent reboot.

cd /tmp;
mkdir EIGEN;
cd  EIGEN;

Get the Eigensoft source code:

tar xzvf EIG3.0.tar.gz;

Install required dependences:

sudo apt-get install f2c libg2c0 libatlas-base-dev liblapack-dev;

This symbolic link is needed as the Makefile links looks for the static version of the library and not the shared version (correct me if I’m wrong, it’s late at night and I could be mistaken):

sudo ln -s /usr/lib/ /usr/lib/;

Build the code:

cd /tmp/EIGEN;
cd src;

Create a backup copy of the Makefile:

cp Makefile;

Edit the Makefile:

emacs -nw Makefile;

Change this line (line 24):


To read as:

FF=”gfortran -std-legacy”

This is needed as the g77 fortran compiler is not longer included with Ubuntu, but you can use the gfortan compiler instead, but you must run it in legacy mode.

Run make:

make eigenstrat;

This next step is essential, because binaries are included in the bin directory that appear to have been build against a 64-bit kernel and are probably artefact’s left over from when the author was testing his code. Also, running “make clean” does not remove the binaries in the bin directory, but does remove those build in the src directory.

make install;

And that should be it run the example.perl in the EIGENSTRAT directory and you should see output like this:

smartpca.perl -i example.geno  -a example.snp  -b example.ind  -k 2  -o example.pca  -p example.plot  -e example.eval  -l example.log  -m 5  -t 2  -s 6.0
smartpca -p example.pca.par >example.log
ploteig -i example.pca.evec -c 1:2  -p Case:Control  -x  -y  -o example.plot.xtxt
evec2pca.perl 2 example.pca.evec example.ind example.pca
smarteigenstrat.perl  -i example.geno  -a example.snp  -b example.ind  -p example.pca  -k 1  -o example.chisq  -l example.log
smarteigenstrat -p example.chisq.par >example.loggc.perl example.chisq example.chisq.GC

If you run into problems running and compiling the code, the README suggests running the following:

make pcatoy;

And, as per the README, contact your sys admin if it doesn’t work. 😉

28 thoughts on “Compiling EIGENSOFT on Ubuntu Januty”

  1. Nice tutorial, I would suggest to use make -B eigenstrat so make will recompile all the dependencies and ignore the old files left by the developer, and make -B pcatoy.

  2. By the way, I was able to build everything by using FF=”gfortran” and typing make -B install.
    When I have tried with the -std-legacy flag for the fortran compiler, I have got some errors, saying that my current gfortran version didn’t recognize such a flag.

    Ubuntu 9.04 with gfortran 4.3.3

  3. Thanks for the comments and suggestion Gioby. I’m glad you found this helpful. I’ll try and test on my Ubuntu 9.10 box and see if it behave the same (my original posting was on 9.04).


  4. Well, i tried this as well, but i got no plot… Dont know why?
    Are there special libraries necessary for the plot?
    Thanks in advance

  5. Very useful guide, Mick, it was such a relief to see your post and hence get the program running on my laptop. I agree with gioby that FF = “gfortran” works fine but not the other way around.

  6. Peter, what version of Ubuntu (or other Linux disto) are you using?

    Recently I upgraded to Ubuntu 9.10 (Karmic) and it doesn’t have the libg2c0 and related libraries. This appears to because it was part of gcc3.x and gcc4 (which Karmic uses) uses gfortran instead. It looks like to use Eigensoft one will have to stick with an older distro, or install the libg2c0 and gcc3 from Ubuntu Jaunty.

    Anyone know if the Eigensoft author plans to move to gcc 4?

  7. > anyone know if the Eigensoft author plans to move to gcc 4?

    I doubt that there are any plans – it’s legacy code – once published, not much pressure to maintain it. One of the many joys of pressure to publish vs benefits to your academic career of the hard yards of maintenance (which is usually zero). I’m a Galaxy developer for the record 🙂

    For doing ancestry PCA, there’s an interesting if quirky alternative called shellfish at
    The error message at the end of that page is an ominous sign…but that seems to be what they’re using at the Welcome trust?

    At least it seems a little more up-to-date than eigensoft3 and the author does respond to email…

  8. Thank you Mick for your helpful tutorial.
    I keep running into the same issue however, a segmentation fault when I try to “make eigenstrat” or “make pcatoy”

    The error is:
    collect2: ld terminated with signal 11 [Segmentation fault]
    /usr/bin/ld: i386:x86-64 architecture of input file `eigenstrat.o’ is incompatible with i386 output

    My naive understanding is that this is due to incompatibilities with a 64 bit OS.
    Do you have any suggestions?

    Thank you again.

  9. Hi Emily,

    I think what happened it that the zip file comes with precompiled binaries for 64-bit Linux. U have to run “make clean” to remove, then recompile.


  10. I am using a windows 7 64 bit machine an also running linux ubuntu 10.04. I want to run EIGENSTRAT on it but when i type make pcatoy it gives me error could not find -lg2c. I tried installing it from debian but still not working. What should i do?

  11. Thanks for post, though not identical this helped me on OS X

    for those trying to compile this on Max OS 10.6, I found this helpful, but needed to do the following instead:

    download the gfortran package (for right os/xcode version) here:
    in my case gfortran 4.2.4

    then in the makefile I had to change
    FF=gfortran -std=legacy (slightly different than here)

    AND change all the linker refs from g2c to gfortran (wherever it says -lg2c in the makefile change it to -lgfortran)

    make clean (or make clobber) to remove old garbage
    make eigenstrat
    make install

    that seemed to work for me

  12. Awesome guide , but can you explain how can I do this without an active internet connection ? I have a messed up speed of 64KB/S … thx in advance

  13. @Brian: thank you for your instructions for mac OSX: they helped me installing Eigensoft on Ubuntu 10.04 !

    The trick consisting in changing FF to FF=gfortran -std=legacy and changing -lg2c to -lgfortran allowed me to compile the programs (I also had to install gfortran: sudo apt-get install gfortran)

  14. Please Let me thank you first!
    My version is eigensoft4.2.
    I got few problems as follows:
    1. When I run this command:sudo apt-get install f2c libg2c0 libatlas-base-dev liblapack-dev; it shows Unable to locate package libg2c0. When I run the command sudo apt-get update, it found BADSIG ……,I tried hard to solve it but I failed ,so I just let it go~I skip to make file
    2. After I run emacs -nw Makefile, I cannot find “FF=g77″(they don’t exist!)
    3. make eigenstrat: It shows make: `eigenstrat’ is up to date
    4. make install: It shows make: *** [convertf] Error 1
    5. ./example.perl:
    An added line was shown up: ../bin/smarteigenstrat: 5: Syntax error: word unexpected (expecting “)”)
    Thank you very much if you can help me at your convenience!
    Maybe you need more infomation: My system is Ubuntu 10.0 i386-64

  15. Hi Xuan,

    For some reason libg2c0 is not available for Ubuntu 10.10. Your options are to either install it from source, download the package from an earlier verison of Ubuntu and install it. Then try and rebuild the Eigensoft source again.

  16. In my case, under ubuntu12.04, with EIG4.2, I had compilation problems;

    To solve it, I did not need to install any package, but just change the Makefile in an unexpected way :
    just move each occurence of ” ($LAPACK) ” character string to the end of the line

    then :
    make clobber
    make install

    and test

  17. I have serious problem to compile EIG4.2… I try to:

    make clobber
    make install

    but get following compilation errors:

    bash-4.2$ make install
    gcc -c -I../include -g -o convertf.o convertf.c
    gcc -c -I../include -g -o mcio.o mcio.c
    gcc -c -I../include -g -o egsubs.o egsubs.c
    gcc -c -I../include -g -o admutils.o admutils.c
    gcc -c -I../include -g -o h2d.o h2d.c
    gcc -c -I../include -g -o eigensrc/exclude.o eigensrc/exclude.c
    gcc -c -I../include -g -o nicksrc/gauss.o nicksrc/gauss.c
    gcc -c -I../include -g -o nicksrc/gds.o nicksrc/gds.c
    gcc -c -I../include -g -o nicksrc/getpars.o nicksrc/getpars.c
    gcc -c -I../include -g -o nicksrc/linsubs.o nicksrc/linsubs.c
    gcc -c -I../include -g -o nicksrc/sortit.o nicksrc/sortit.c
    gcc -c -I../include -g -DTWTAB=”../src/smarttables/twtable” -o nicksrc/statsubs.o nicksrc/statsubs.c
    gcc -c -I../include -g -o nicksrc/strsubs.o nicksrc/strsubs.c
    gcc -c -I../include -g -o nicksrc/vsubs.o nicksrc/vsubs.c
    gcc -c -I../include -g -o nicksrc/xsearch.o nicksrc/xsearch.c
    ar -r nicksrc/libnick.a nicksrc/gauss.o nicksrc/gds.o nicksrc/getpars.o nicksrc/linsubs.o nicksrc/sortit.o nicksrc/statsubs.o nicksrc/strsubs.o nicksrc/vsubs.o nicksrc/xsearch.o
    gcc -I../include -pthread convertf.o mcio.o egsubs.o admutils.o h2d.o eigensrc/exclude.o nicksrc/libnick.a -o convertf -lm
    gcc -c -I../include -g -o mergeit.o mergeit.c
    gcc -I../include -pthread mergeit.o mcio.o admutils.o nicksrc/libnick.a -o mergeit -lm
    gcc -c -I../include -g -o eigensrc/smartpca.o eigensrc/smartpca.c
    gcc -c -I../include -g -o twsubs.o twsubs.c
    gcc -c -I../include -g -o qpsubs.o qpsubs.c
    gcc -c -I../include -g -o regsubs.o regsubs.c
    gcc -c -I../include -g -o eigensrc/eigsubs.o eigensrc/eigsubs.c
    gfortran -c -I../include -g -o eigensrc/eigx.o eigensrc/eigx.f
    gcc -c -I../include -g -o eigensrc/workqueue.o eigensrc/workqueue.c
    gfortran -I../include -pthread -o smartpca -llapack eigensrc/smartpca.o twsubs.o mcio.o qpsubs.o admutils.o egsubs.o regsubs.o eigensrc/eigsubs.o eigensrc/eigx.o eigensrc/workqueue.o eigensrc/exclude.o nicksrc/libnick.a -lm
    /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/ undefined reference to `cgemv_’

    /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/ undefined reference to
    /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/ undefined reference to `ztbmv_’
    collect2: error: ld returned 1 exit status
    make: *** [smartpca] Error 1

    Anyone know what to do?

    Edited by Mick for brevity.

  18. A.T.A. : It looks like your missing some dependencies, or you have the wrong libraries installed.

    What does the following command show:

    “ldd /usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/”

  19. quentin300, thank you a LOT!!

    As you, I tried compiling EIGENSOFT 4.2 under Ubuntu 12.04, but to no avail. That is, until trying your solution.

    If anyone wonders how to do it exactly, I changed this line:
    $(FC) $(LDFLAGS) -o $@ $(LAPACK) $^ $(MATHLIB)
    $(FC) $(LDFLAGS) -o $@ $^ $(MATHLIB) $(LAPACK)
    (There are multiple lines where LAPACK is not the last one on the line, I guess all these need to be changed.)

    This solved errors like:
    eigensrc/eigx.o: In function `eigx_’: undefined reference to `dspev_’
    eigensrc/eigx.o: In function `eigxv_’: undefined reference to `dspev_’
    and references to dpotrf_ dgetri_ dgetrs_

    (Putting them here hoping Google will index it so it may help others.)

    Thanks again!

  20. Recently recompile the Eigensoft 4.2 on a Mac OS 10.8.

    ./src/nicksrc/libnick.a should be delete in addition besides the “make clobber”, otherwise “ld: symbol(s) not found for architecture x86_64” will happen.

  21. Hi Wenbo

    I am trying to recompile the Eigensoft 4.2 on Mac OS 10.8

    But it doesnot work ,will you please tell me how to do that?

    My email

    Many thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.