Page MenuHomePhabricator

pthread not found in applications using thread
Open, NormalPublic


in Etui, i use threads. I have this error :

In file included from /usr/include/eina-1/eina/eina_inline_lock_posix.x:35,
                 from /usr/include/eina-1/eina/eina_lock.h:100,
                 from /usr/include/eina-1/Eina.h:250,
                 from ../src/lib/etui_file.c:24:
/usr/include/pthread.h: At top level:
/usr/include/pthread.h:889:33: error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
  889 | extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
      |                                 ^~~~~~~~~~~~~~~~
      |                                 pthread_cond_t

is it normal that I have to specify in etui's that I need to link against pthread ? Shouldn't instead eina.pc pass -lpthread to Libs ?

vtorri created this task.Oct 7 2019, 2:21 AM
vtorri triaged this task as Normal priority.

My eina.pc contains -lpthread ...

vtorri added a comment.Oct 9 2019, 3:26 AM

it is garded. adding -D_POSIX_C_SOURCE=200809L in eina.pc (in CFlags) should be sufficient

#if defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Data structure for reader-writer lock variable handling.  The
   structure of the attribute type is deliberately not exposed.  */
typedef union
  struct __pthread_rwlock_arch_t __data;
  char __size[__SIZEOF_PTHREAD_RWLOCK_T];
  long int __align;
} pthread_rwlock_t;
bu5hm4n edited projects, added efl: data types; removed efl.Oct 9 2019, 4:17 AM
bu5hm4n removed bu5hm4n as the assignee of this task.
bu5hm4n added a subscriber: bu5hm4n.

This needs some solving in either your app or eina, but not in meson. eina.pc should not force you to -D_POSIX_C_SOURCE i guess. autotools also never did that.

AJSlye added a subscriber: AJSlye.EditedOct 9 2019, 5:55 AM

Well, my eina.pc contains -pthread and I have the same issue/errors.

Now, even if I change the eina.pc lines to -lpthread, I still get the same errors.

vtorri added a comment.Oct 9 2019, 5:58 AM

@bu5hm4n i would say in eina as a user should not do extra work. Eina is using some features, it should enable them, imho.

raster added a comment.Oct 9 2019, 7:26 AM

eina headers have to solve this because eina_inline_lock_posix.x has the implementation and it needs to #define enough to ensure the headers it has other 3rd part apps use have everything working. so:

#define _POSIX_C_SOURCE=200809

inside eina_inline_lock_posix.x at the top right after:


@vtorri - can you try adding that there and see if it helps you? i assume this is not on windows in this case.

vtorri added a comment.Oct 9 2019, 7:39 AM

@raster i've asked the user to export it to CPPFLAGS and issue vanished of course. I will provide a diff

vtorri added a comment.Oct 9 2019, 7:46 PM

@raster btw, eina_inline_posix_lock.x does:

#include <errno.h>
#ifndef __USE_UNIX98
# define __USE_UNIX98
# include <pthread.h>
# undef __USE_UNIX98
# include <pthread.h>

so normally, __USE_UNIX_98 is defined before inclusion of pthread.h, hence ( pthread_rwlock_t is defined, right ?

vtorri added a comment.EditedOct 9 2019, 8:04 PM

we can also increase _XOPEN_SOURCE to 700 (