Search code examples
haskelllinkercaballinux-minteuterpea

Haskell ghc, linking error when trying to compile a program using ghc and Euterpea


I'm checking out the computing music development library Euterpea and I'm trying to compile the following basic program:

import Euterpea

    t251 :: Music Pitch
    t251 = let dMinor = d 4 wn :=: f 4 wn :=: a 4 wn
               gMajor = g 4 wn :=: b 4 wn :=: d 5 wn
               cMajor = c 4 bn :=: e 4 bn :=: g 4 bn
           in dMinor :+: gMajor :+: cMajor

    main = play t251

the program works fine inside ghci, but when I try to compile it using ghc test.hs I get the following error message:

Linking test ... /usr/bin/ld: /home/fayong/.cabal/lib/PortMidi-0.1.3/ghc-7.6.3/libHSPortMidi-0.1.3.a(ptlinux.o): undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

It seems to be a linking error but I don't know how to fix it. I tried to pass -lpthread as an option but it didn't work either.

I installed Euterpea via cabal, on linux mint 17


Solution

  • I got the same error and fixed it by running ghc with the '-threaded' option. I think it has something to do with a recent update to the play, but I will have to look into it more.