Bug 9094 - needs to link with -lpthread due to mutex usage in libgoo
Summary: needs to link with -lpthread due to mutex usage in libgoo
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86 (IA32) other
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-20 05:08 UTC by Michael Banck
Modified: 2011-06-19 15:12 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
proposed patch (344 bytes, patch)
2006-11-20 05:09 UTC, Michael Banck
Details | Splinter Review

Description Michael Banck 2006-11-20 05:08:48 UTC
goo/GooMutex.h includes <pthread.h> and defines pthread_mutex_* aliases which
are used in poppler.  Those become undefined references on platforms which do
not include libpthread in libc:

g++ -Wall -Wno-unused -g -Wall -O2 -o .libs/pdffonts pdffonts.o parseargs.o 
../poppler/.libs/libpoppler.so -lfontconfig /usr/lib/libjpeg.so
/usr/lib/libfreetype.so -lz
../poppler/.libs/libpoppler.so: undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
make[3]: *** [pdffonts] Error 1

This is the case e.g. on GNU/Hurd, which has its own libpthread library outside
of glibc currently.  Adding -lpthread to libpoppler_la_LDFLAGS in
poppler/Makefile.am makes poppler build fine on these platforms.  I am not sure
whether this might have negative side-effects (all programs using libpoppler
getting -lpthread as well, maybe?), so there might be a better fix.
Comment 1 Michael Banck 2006-11-20 05:09:33 UTC
Created attachment 7840 [details] [review]
proposed patch
Comment 2 Albert Astals Cid 2006-11-20 11:01:19 UTC
does adding -pthread to gcc CXXFLAGS works also for you?
Comment 3 Michael Banck 2006-11-22 09:13:02 UTC
(In reply to comment #2)
> does adding -pthread to gcc CXXFLAGS works also for you?

Yes, that makes it build fine as well, though I am not sure adding it always is
desired, but I am not sure about the implications.
Comment 4 Samuel Thibault 2006-11-26 13:02:15 UTC
On some systems (like OSF), adding -pthread in compiler flags is needed as soon as you include pthread.h.  So this is needed whenever you include GooMutex.h. 
Comment 5 Michael Banck 2008-01-01 15:58:52 UTC
What's the status of this?  Did it get fixed in the meantime?


Michael
Comment 6 Brad Hards 2008-01-01 22:16:47 UTC
It doesn't look to be fixed. Only the Qt3 bindings have anything that I can see related to pthread.

The original patch can't go in as-is though (because it will break on anything that doesn't have a libpthread). 

Could you possibly have a look at the m4/qt4.m4 code, and try to come up with an equivalent test? It should try to compile some problematic code, and only add -lpthread if it breaks.
Comment 7 Albert Astals Cid 2011-06-19 14:58:53 UTC
3 years and no answer to Brad questions so i understand you guys are not interested in this anymore, closing it as wontfix. Reopen if you become interested again
Comment 8 Samuel Thibault 2011-06-19 15:12:15 UTC
I have to say I don't remember having seen Brad questions.
Anyway, in the meantime goo stopped using aliases, and with the
libpthread-stubs library, hurd now has pthread_mutex_* weak symbols
which make poppler build, so it's actually fixed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.