openssl: [TEMP. FIX] undefined reference to `pthread_atfork'
Hi. I’m trying to build Nginx with this script, but I get this error.
objs/addon/src/ngx_http_brotli_filter_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lpthread -lcrypt -lm ../pcre-8.41/.libs/libpcre.a ../openssl/.openssl/lib/libssl.a ../openssl/.openssl/lib/libcrypto.a -ldl ../libatomic_ops-7.6.0/src/libatomic_ops.a \
-Wl,-E
../openssl/.openssl/lib/libcrypto.a(threads_pthread.o): In function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x1ba): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
make[1]: *** [objs/Makefile:309: objs/nginx] Error 1
I was able to build two weeks ago, so this issue must be new.
[EDIT] See the temporary fix.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (14 by maintainers)
Commits related to this issue
- Add anything specifying a threads library to ex_libs Even -pthread gets treated that way. The reason to do this is so it ends up in 'Libs.private' in libcrypto.pc. Fixes #3884 — committed to levitte/openssl by levitte 6 years ago
- Add anything specifying a threads library to ex_libs Even -pthread gets treated that way. The reason to do this is so it ends up in 'Libs.private' in libcrypto.pc. Fixes #3884 — committed to levitte/openssl by levitte 6 years ago
- Add anything specifying a threads library to ex_libs Even -pthread gets treated that way. The reason to do this is so it ends up in 'Libs.private' in libcrypto.pc. Fixes #3884 Reviewed-by: Bernd E... — committed to openssl/openssl by levitte 6 years ago
So finally, It seems that the Nginx configuration file is quite odd. So the the temporary solution for now is a hack. After running the
./configure, inobj/Makefile, you should remove the first-lpthreadand move the second to the end of the line, right before\. Since the github repo. of Nginx is just a mirror, I can’t submit an issue about this.Thanks to all of you who supported me through this whole issue.
You should use “-pthread”, not “-lpthread”.
-lpthread will probably also work if you move it to the end of the libraries.
For some reason you’re also using a static version of all the libraries. I suggest you use shared versions instead if you can. Your OS should already provide shared versions of those libraries.
nginx 1.13.11 fix
you should use “–with-ld-opt=-pthread”
For those who want a scripted temporary solution:
It looks to me like this is an order problem:
Shouldn’t
-lpthreadappear last to make sure the symbol references inlibcrypto.aget properly resolved?