jwiegley / gitlib

180 stars 56 forks source link

missing pthread dependency #35

Closed jamespharaoh closed 10 years ago

jamespharaoh commented 10 years ago

I get errors when trying to compile using gitlib-libgit2:

Linking git-tool ... /usr/bin/ld: /home/james/lib/haskell/cabal/lib/hlibgit2-0.18.0.13/ghc-7.8.3/libHShlibgit2-0.18.0.13.a(global.o): referencia sin definir al símbolo 'pthread_key_delete@@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

Adding pthread to the extra-libraries for hlibgit2 fixes this problem.

jwiegley commented 10 years ago

Thanks, but I think this should only apply on Linux.

jamespharaoh commented 10 years ago

According to the libgit2 README:

libgit2 builds cleanly on most platforms without any external dependencies. Under Unix-like systems, like Linux, *BSD and Mac OS X, libgit2 expects pthreads to be available; they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API for threading.

The bit I modified is already in the else section of an "if os(windows)", which seems right to me. It also doesn't seem like it should cause any problems even if it's not needed. I think pthread is a fairly standard library.

I'm not an expert in linkers but I have a feeling the problem is being caused by references to pthreads from the header files and so being compiled into the hlibgit2 library itself. There are plenty of references in libgit2 source, in common.h and thread-utils.h.

What platforms do you know this to work on? Bear in mind this doesn't show up until you try to compile a project which uses the hlibgit2 module rather than running it interpreted. I have a suspicion that this problem is quite widespread. I could do some testing on different systems if that will help.