jashobant
jashobant

Reputation: 21

What library to be to be used to avoid undefined reference to `pthread_atfork'

I get undefined reference to `pthread_atfork' even after using pthread library. Is there any separate library for this?

Upvotes: 2

Views: 10095

Answers (2)

Hans-Christoph Steiner
Hans-Christoph Steiner

Reputation: 2682

If you are building for Android, then pthread_atfork() is not included in Bionic libc. Check out this question for more information:

"undefined reference to pthread_atfork" while I was trying to port libpcsclite to Android

Upvotes: 1

David Gelhar
David Gelhar

Reputation: 27900

pthread_atfork() is part of the POSIX spec, so it should be there in the regular pthread library.

You may have to specify options to both the compiler & linker to build with pthreads. For example, with gcc/linux:

-pthread
       Adds support for multithreading with the pthreads library.  This option sets flags for both the
       preprocessor and linker.

Upvotes: 2

Related Questions