跳到主要内容

undefined reference to `pthread_mutex_lock`

·67 字
root@crazy:/home/src/php-7.0.15# mips-openwrt-linux-uclibc-gcc -g -O2 -fvisibility=hidden ext/date/php_date.o ext/date/lib/astro.o ext/date/lib/dow.o ... sapi/cli/php_cli_server.o sapi/cli/ps_title.o sapi/cli/php_cli_process_title.o -o sapi/cli/php -lcrypt -lm -static
...
ext/pcre/pcrelib/pcre_jit_compile.o: In function allocator_grab_lock:
/home/src/php-7.0.15/ext/pcre/pcrelib/sljit/sljitUtils.c:117: undefined reference to `pthread_mutex_lock
ext/pcre/pcrelib/pcre_jit_compile.o: In function allocator_release_lock:
/home/src/php-7.0.15/ext/pcre/pcrelib/sljit/sljitUtils.c:122: undefined reference to `pthread_mutex_unlock
...
collect2: error: ld returned 1 exit status

查了半天资料 发现 只要加一句 -lpthread 即可。

root@crazy:/home/src/php-7.0.15# file sapi/cli/php
sapi/cli/php: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, statically linked, not stripped

终于有静态的了