bootchk / resynthesizer

Suite of gimp plugins for texture synthesis
GNU General Public License v3.0
1.47k stars 163 forks source link

Explicit gthread linking required #9

Closed Sentynel closed 12 years ago

Sentynel commented 12 years ago

Building on an Ubuntu 12.04 system, build fails with the following error:

gcc -g -O2 -Wall -o resynthesizer resynthesizer.o engineParams.o imageFormat.o -lgimpui-2.0 -lgimpwidgets-2.0 -lgimpmodule-2.0 -lgimp-2.0 -lgimpmath-2.0 -lgimpconfig-2.0 -lgimpcolor-2.0 -lgimpbase-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 libimagesynth.a -lm resynthesizer.c:314: error: undefined reference to 'g_thread_init' refinerThreaded.h:319: error: undefined reference to 'g_thread_init' collect2: ld returned 1 exit status make[2]: *\ [resynthesizer] Error 1 make[2]: Leaving directory `/home/sam/devel/resynthesizer/src'

Manually adding -lgthread-2.0 to GIMP_LIBS in src/Makefile fixes it. I guess something needs to be changed in the autoconf magic, but I have no idea how that works and a quick grep didn't reveal any obvious candidates.

orbisvicis commented 12 years ago
sed -i 's/LDADD.*/\0 -lgthread-2.0/' src/Makefile.am
bootchk commented 12 years ago

Thanks. Please give your advice on the following question:

g_thread_init() is deprecated in glib starting at some (that I can't say without looking it up) version of glib. Should I eliminate g_thread_init from the code? That might break resynthesizer for users of older versions of glib.

I don't know whether lgthread-2.0 exists in older versions of GLIB. I would guess that it does exist in older versions of GLIB, and that this build error is about a change in the linker: it no longer links in dependent libraries. See the resynthesizer issue about not building because lmath was not explicitly specified in LDADD.

On the other hand, it seems strange that only g_thread_init() is undefined and not all the threading functions ofGLIB. Maybe lgthread-2.0 is a compatibility library only included in newer versions of GLIB?

Bottom line: I am still studying the issue. I am open to your fix. I am not yet sure it is backward compatible for older GLIB.

Sentynel commented 12 years ago

libgthread-2.0 is present at least as far back as glib 2.16 from early 2008 (I checked the package in Ubuntu Hardy), so explicitly linking it should be safe.

I wouldn't recommend dropping the old threading API entirely at this point; glib 2.32 (which is where that API was deprecated) only came out this year. You could #ifdef the functions in question (the changes affect more than g_thread_init(); there's a list of deprecated functions here), but I'm not sure there'd be any particular benefit to doing that.

bootchk commented 12 years ago

Thanks. Fixed.