Of 'shm_open' undefined reference

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/iefenghao/article/details/89479133

Compile error:

Of 'shm_open' undefined reference

the reason:

General cause of the error is caused no link library

Solution:

In compiling the final add -lrt

E.g:

gcc -o test test.c -lrt

The last few lines of man shm_open Help file:

NOTES

       These functions are provided in glibc 2.2 and  later.   Programs  using

       these  functions  must  specify  the  -lrt  flag to cc in order to link

       against the required ("realtime") library.
 

Guess you like

Origin blog.csdn.net/iefenghao/article/details/89479133