GNOME Bugzilla – Bug 739201
openh264: configure check requires -pthread on ubuntu (broken compiler defaults ?)
Last modified: 2018-05-04 10:01:50 UTC
-bad's config.log: configure:46562: *** checking feature: openh264 library *** configure:46566: *** for plug-ins: openh264 *** configure:46615: checking for WelsSnprintf in -lopenh264 configure:46640: ccache g++ -o conftest -Wall -g -O2 -m64 -Wall -g -O2 -m64 -Wall -g -O2 -m64 -Wno-error -Wno-error -L/var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib -m64 -m64 -m64 conftest.cpp -lopenh264 >&5 /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_init' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_destroy' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_timedwait' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `pthread_create' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_post' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_trywait' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `sem_wait' /var/lib/jenkins/workspace/cerbero-debian/workdir/dist/linux_x86_64/lib/libopenh264.so: undefined reference to `pthread_join' collect2: error: ld returned 1 exit status configure:46640: $? = 1
hmm... this might actually be because of some broken pthread detection on that debian machine, we end up with PTHREAD_LIBS='' ... checking for the pthreads library -lpthreads... no checking whether pthreads work without any flags... no checking whether pthreads work with -Kthread... no checking whether pthreads work with -kthread... no checking for the pthreads library -llthread... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking if more special flags are required for pthreads... no checking whether to check for GCC pthread/shared inconsistencies... yes checking whether -pthread is sufficient with -shared... yes checking for unistd.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for stdint types... stdint.h (shortcircuit) make use of stdint.h in _stdint.h (assuming C99 compatible system) checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes ... Would this maybe be because the check for -lpthread requirement is done on the C compiler and not the C++ compiler ?
What exactly is required to give to the C++ compiler here? It sounds like the C compiler can find the symbols without linking to any libs at all... but the C++ compiler needs to use -lpthread? That seems wrong. What exactly is the configure check testing there?
Note that PTHREAD_CFLAGS is "-pthread" here on my debian sid machine, but PTHREAD_CFLAGS isn't used anywhere (even if just gcc was used).
content of config.log: configure:24258: checking whether pthreads work with -pthread configure:24343: ccache gcc -std=gnu99 -o conftest -Wall -g -O2 -m64 -Wall -g -O2 -m64 -Wall -g -O2 -m64 -Wno-error -pthread -Wno-error -L/var/lib/jenkins/workspace/cerber conftest.c: In function 'main': conftest.c:45:1: warning: missing braces around initializer [-Wmissing-braces] pthread_t th; pthread_attr_t attr = {0, }; ^ conftest.c:45:1: warning: (near initialization for 'attr.__size') [-Wmissing-braces] configure:24343: $? = 0 configure:24352: result: yes So on this machine (debian buildslave), we *need* -pthread. Looking more in details at how other checks for libraries that also require -pthread work .. they suceed because .pc provides -pthread in the CFLAGS. If only openh264 had a .pc ...
(In reply to comment #4) > If only openh264 had a .pc ... It now has :)
Created attachment 289511 [details] config.log config.log for when it works
Created attachment 289512 [details] config.log this time with gcc instead of clang
so by the looks of things ... g++ on ubuntu is a bit of a trainwreck : https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201 Essentially it won't link libpthread by default if you use -pthread Unsure what workaround we could use...
No one has complained in 4 years so hopefully Ubuntu fixed their compiler by now. Please re-open if it's still an issue.