# shm\_open shm\_unlink not found

**URL:** https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749
**Category:** Code
**Created:** [March 22, 2023, 10:45am UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749 "2023-03-22T10:45:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![a\_lex12](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@a\_lex12](https://discourse.cmake.org/u/a_lex12)
#### Post date: [March 22, 2023, 10:45am UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/1 "2023-03-22T10:45:47Z")

</div>

I am new to CMake and trying to build a project for aarch64 armv8 from Termux on my android phone. I am running into this error:  
gcc -o ex main.c -lc  
main.c:19:10: warning: call to undeclared function ‘shm\_open’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]  
fd = shm\_open(“/my\_shm”, O\_CREAT | O\_RDWR, S\_IRUSR | S\_IWUSR);  
^  
1 warning generated.  
ld.lld: error: undefined symbol: shm\_open

> > > referenced by main.c  
> > > /data/data/com.termux/files/usr/tmp/main-8f7dab.o:(main)  
> > > did you mean: sem\_open  
> > > defined in: /system/lib64/libc.so  
> > > clang-15: error: linker command failed with exit code 1 (use -v to see invocation

I found from googling that libc includes these functions and according to the fact that the error messaage suggests me to use \>\>\> did you mean: sem\_open I assume that the libc was found in my termux environment, or not? Any help or hints are very appreciated as I wasted a couple of hours already to try to fix that.

I uploaded a small project that reproduces my problem on termux from an android phone: [GitHub - alexg93333/cmaketest](https://github.com/alexg93333/cmaketest)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 22, 2023, 12:27pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/2 "2023-03-22T12:27:54Z")

</div>

`shm_open` comes from `librt` and must be linked separately with `-lrt`.

---

<div class="post-metadata">

### Author: ![a\_lex12](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@a\_lex12](https://discourse.cmake.org/u/a_lex12)
#### Post date: [March 22, 2023, 12:41pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/3 "2023-03-22T12:41:05Z")

</div>

I get the exact same error with -lrt. I checked my /system/lib64/ path and libc.so is there. librt.so is missing. What does that mean?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 22, 2023, 1:13pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/4 "2023-03-22T13:13:08Z")

</div>

This sounds like a different kind of system/platform. But I’d expect an error about `librt.so` to be missing, not a missing symbol in this case anyways.

---

<div class="post-metadata">

### Author: ![a\_lex12](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@a\_lex12](https://discourse.cmake.org/u/a_lex12)
#### Post date: [March 22, 2023, 1:32pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/5 "2023-03-22T13:32:43Z")

</div>

In my CMakeLists.txt I executed:  
FIND\_LIBRARY(RT\_LIBRARY rt)  
message(${RT\_LIBRARY})

it returns this path:  
/data/data/com.termux/files/usr/lib/librt.so

the content of this file is just:  
INPUT -lc

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 22, 2023, 1:36pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/6 "2023-03-22T13:36:34Z")

</div>

No idea. Might be a question for Termux folks. Maybe `shm_open` isn’t implemented in Bionic?

---

<div class="post-metadata">

### Author: ![a\_lex12](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@a\_lex12](https://discourse.cmake.org/u/a_lex12)
#### Post date: [March 22, 2023, 1:38pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/7 "2023-03-22T13:38:47Z")

</div>

I found a librt.so in my linux VM on my PC. Can I just copy it to my phone and use it?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 22, 2023, 1:41pm UTC](https://discourse.cmake.org/t/shm-open-shm-unlink-not-found/7749/8 "2023-03-22T13:41:22Z")

</div>

No. I suspect that the Android way is something like Binder or the like, but it’s really a question more for an Android development forum than CMake (as CMake cannot make function appear from nowhere if they’re not implemented on the target).
