Libuv: pthread_rwlock_t undefined on unix platform (ubuntu 16.10) with libuv 1.10.1 rebuild

Created on 5 Dec 2016  Â·  10Comments  Â·  Source: libuv/libuv

With simple inclusion of 'uv.h', gcc complains about 'pthread_rwlock_t' type unknown.

In file included from /home/vincent/usr/include/uv.h:62:0,
from /home/vincent/bozCommand/comps/libuv/files/test/helloworld.c:3:
/home/vincent/usr/include/uv-unix.h:137:9: error: unknown type name ‘pthread_rwlock_t’
typedef pthread_rwlock_t uv_rwlock_t;
^~~~

Most helpful comment

For future searchers with the same problem:

-std=c99 requests strict POSIX compliance; no extensions like pthread_rwlock_t. Use -std=gnu99 instead.

(Same for -std=c11: use -std=gnu11.)

All 10 comments

How are you compiling your application? Does libuv (and the test suite) compile?

of course my lib is built and installed.
I used autogen and configure (by default) to install on $HOME/usr prefix.
'make check' succeeded without any issues.

/home/vincent/usr/include/uv.h installed header.
/home/vincent/bozCommand/comps/libuv/files/test/helloworld.c is my file to compile.

my platform is ubuntu x64 16.10 with only native compiler gcc.

Can you paste your example code and how you're compiling it? The test suite uses locks, so the problem must be elsewhere.

include

include

include

int main() {
uv_loop_t *loop = malloc(sizeof(uv_loop_t));
uv_loop_init(loop);

printf("Now quitting.\n");
uv_run(loop, UV_RUN_DEFAULT);

uv_loop_close(loop);
free(loop);
return 0;

}

what is the exact command line you are using to compile?

gcc -Wall -Werror -o test main.c

sorry complete command line is
/usr/bin/cc -I.include/public -I.include -I./comps/fork/files/include -I/usr/include -Wmissing-prototypes -Wbad-function-cast -Wshadow -Wfloat-equal -Wswitch-default -Wno-unused-result -O0 -ggdb -std=c99 -Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wunknown-pragmas -Wformat-security -Wstrict-aliasing -Wreturn-type -Wmissing-noreturn -o comps/fork/files/app/child.c.o -c comps/fork/files/app/child.c

You need to have -lpthread. Or use pkg-config and get the required flags out of the installed pc file.

Closing since it's not a libuv issue.

For future searchers with the same problem:

-std=c99 requests strict POSIX compliance; no extensions like pthread_rwlock_t. Use -std=gnu99 instead.

(Same for -std=c11: use -std=gnu11.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trevnorris picture trevnorris  Â·  7Comments

bnoordhuis picture bnoordhuis  Â·  9Comments

alishir picture alishir  Â·  6Comments

jorangreef picture jorangreef  Â·  9Comments

justinmk picture justinmk  Â·  5Comments