Skip to content

include pthread in app -> compilation failed #6984

@ehudmarvell

Description

@ehudmarvell

Hi,

I tried to compile "hello world" with "pthread" include but compilation fail (without pthread compilation pass).

my compilation steps:
rm -rf build && mdir build && cd build;
cmake -GNinja -DBOARD=qemu_x86 ..
ninja

#include <zephyr.h>
#include <misc/printk.h>
#include <pthread.h>

void main(void)
{
	printk("Hello World! %s\n", CONFIG_ARCH);
}

I got the following errors:

.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj   -c ../src/main.c
In file included from /home/ehudn/work/zephyr/zephyr/include/posix/time.h:26:0,
                 from /home/ehudn/work/zephyr/zephyr/include/posix/pthread.h:11,
                 from ../src/main.c:9:
/home/ehudn/work/zephyr/zephyr/include/posix/signal.h:37:2: error: unknown type name ‘pthread_attr_t’
  pthread_attr_t *sigev_notify_attributes;
  ^~~~~~~~~~~~~~
In file included from /home/ehudn/work/zephyr/zephyr/include/posix/pthread.h:11:0,
                 from ../src/main.c:9:
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:52:33: error: unknown type name ‘clockid_t’
 static inline int clock_settime(clockid_t clock_id, const struct timespec *ts)
                                 ^~~~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:58:19: error: unknown type name ‘clockid_t’
 int clock_gettime(clockid_t clock_id, struct timespec *ts);
                   ^~~~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:60:18: error: unknown type name ‘clockid_t’
 int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid);
                  ^~~~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:60:59: error: unknown type name ‘timer_t’
 int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid);
                                                           ^~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:61:18: error: unknown type name ‘timer_t’
 int timer_delete(timer_t timerid);
                  ^~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:62:19: error: unknown type name ‘timer_t’
 int timer_gettime(timer_t timerid, struct itimerspec *its);
                   ^~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/time.h:63:19: error: unknown type name ‘timer_t’
 int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
                   ^~~~~~~
In file included from /home/ehudn/work/zephyr/zephyr/include/posix/pthread.h:12:0,
                 from ../src/main.c:9:
/home/ehudn/work/zephyr/zephyr/include/posix/unistd.h:16:12: error: unknown type name ‘useconds_t’
 int usleep(useconds_t useconds);
            ^~~~~~~~~~
In file included from ../src/main.c:9:0:
/home/ehudn/work/zephyr/zephyr/include/posix/pthread.h:37:2: error: unknown type name ‘pthread_mutex_t’
  pthread_mutex_t cancel_lock;
  ^~~~~~~~~~~~~~~
/home/ehudn/work/zephyr/zephyr/include/posix/pthread.h:41:2: error: unknown type name ‘pthread_mutex_t’
  pthread_mutex_t state_lock;

Should I add some POSIX flag into prj.conf? or into CMakeLists.txt?

Thanks!

Metadata

Metadata

Labels

area: POSIXPOSIX API LibrarybugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions