“undefined reference to symbol” error when using `ld` to link
问题 I am new to writing programs on Linux. I have a single module program that uses shm_open , ftruncate , mmap , fork , and wait . I compiled this program with gcc -c and then linked it with ld -lrt (librt is needed for shm_open ) and I got a strange linker error: undefined reference to symbol 'waitpid@@GLIBC_2.2.5' The manpage for wait says Feature Test Macro Requirements for glibc (see feature_test_macros(7)): waitid(): Since glibc 2.26: _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L Glibc