bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
12.25k stars 1.53k forks source link

libcamera.so.0: cannot open shared object file: No such file or directory #1195

Closed rasulovk closed 2 years ago

rasulovk commented 2 years ago

Which version are you using?

v0.20.0

Which operating system are you using?

Describe the issue

Description

Describe how to replicate the issue

  1. start the server
  2. publish with Pi camera.
  3. crash on start with error message "error while loading shared libraries: libcamera.so.0"

Did you attach the server logs?

LOGS: root@picamera:/home/pi# ./rtsp-simple-server 2022/10/17 19:12:14 INF rtsp-simple-server v0.20.0 2022/10/17 19:12:14 INF [path cam] [rpicamera source] started /dev/shm/rtspss-embeddedexe-1666019534490556762: error while loading shared libraries: libcamera.so.0: cannot open shared object file: No such file or directory 2022/10/17 19:12:14 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP) 2022/10/17 19:12:14 INF [RTMP] listener opened on :1935 2022/10/17 19:12:14 INF [path cam] [rpicamera source] ERR: process exited unexpectedly 2022/10/17 19:12:14 INF [HLS] listener opened on :8888

yes

Did you attach a network dump?

no

ernovout commented 2 years ago

I'm suffering from this same issue (with v0.20.1). I looked into this a little bit but cannot quite pinpoint the root cause. I'll share my findings here though.

1. libcamera files on disk

I made a simple find on the disk to see what type of libcamera files I have available.

$ sudo find / -type f -name "libcamera*"
/var/lib/dpkg/info/libcamera0:armhf.md5sums
/var/lib/dpkg/info/libcamera-dev:armhf.list
/var/lib/dpkg/info/libcamera-dev:armhf.md5sums
/var/lib/dpkg/info/libcamera-apps-lite.triggers
/var/lib/dpkg/info/libcamera0:armhf.list
/var/lib/dpkg/info/libcamera0:armhf.triggers
/var/lib/dpkg/info/libcamera-apps-lite.list
/var/lib/dpkg/info/libcamera-apps-lite.md5sums
/var/lib/dpkg/info/libcamera0:armhf.shlibs
/usr/lib/arm-linux-gnueabihf/pkgconfig/libcamera-base.pc
/usr/lib/arm-linux-gnueabihf/pkgconfig/libcamera.pc
/usr/lib/arm-linux-gnueabihf/libcamera-base.so.0.0.1
/usr/lib/arm-linux-gnueabihf/libcamera.so.0.0.1
/usr/lib/arm-linux-gnueabihf/libcamera_app.so
/usr/bin/libcamera-vid
/usr/bin/libcamera-raw
/usr/bin/libcamera-still
/usr/bin/libcamera-hello
/usr/bin/libcamera-jpeg
/usr/include/libcamera/libcamera/libcamera.h
/usr/share/lintian/overrides/libcamera-dev

So the closest match to "libcamera.so.0" would actually be "libcamera.so.0.0.1".

2. Building internal/rpicamera from source fails

I tried downloading the v0.20.1 tar.gz and building internal/rpicamera from it, but I get a build error like this:

~/rtsp-simple-server-0.20.1/internal/rpicamera/exe $ sudo make -j2
g++ -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -std=c++17 $(pkg-config --cflags libcamera) -c camera.cpp -o camera.o
gcc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c encoder.c -o encoder.o
gcc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c main.c -o main.o
gcc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c parameters.c -o parameters.o
gcc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c roi.c -o roi.o
gcc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c sensor_mode.c -o sensor_mode.o
camera.cpp: In function ‘bool camera_start(camera_t*)’:
camera.cpp:307:63: error: conversion from ‘std::optional<libcamera::Rectangle>’ to non-scalar type ‘libcamera::Rectangle’ requested
  307 |         Rectangle sensor_area = camp->camera->properties().get(libcamera::properties::ScalerCropMaximum);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:39: camera.o] Error 1

I did install the dependencies as shown in scripts/binaries.mk.

$ gcc --version
gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110

$ g++ --version
g++ (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110

$ c++ --version
c++ (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110

I hope this helps 🤷 I don't really do C or C++ so getting to the bottom of this is a bit cumbersome 😬

aler9 commented 2 years ago

Hello, the reason behind all this is that some days ago libcamera received an update that broke compatibility with all existing software that uses it. The library name was changed from libcamera.so.0.0.0 to libcamera.so.0.0.1, so everything that is linked against the first one is now broken.

These kind of changes shouldn't be distributed with automatic updates, in particular this is the latest in a series of breaking changes related to the software part of the Raspberry Pi camera that made using the camera quite hard.

Anyway, the server will be recompiled soon in order to restore compatibility. If it happens again, we'll think about another strategy.

andreanidouglas commented 2 years ago

just build it from source GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server -tags rpicamera

it worked fine! thanks for this project @aler9

aler9 commented 2 years ago

Fixed in v0.20.2

yllekz commented 1 year ago

Hello, I'm getting this error with the latest container on a Pi 4B. I don't have the slightest clue as to how to fix it. I'm just following the main guide. No mention of having to build things from source. Fully patched and set up according to the guide. What's going on here?

Figured it out.....Not sure why, but I ended up doing a full OS reinstall to get it working though. Not ideal, but I guess that was what I had to do.

madison8935 commented 1 year ago

I have the same issue.

Freshly set up Pi with apt update/upgrade run. Publish rpiCamera. Starting the server and getting this error message:

/dev/shm/rtspss-embeddedexe-1670339500620395915: error while loading shared libraries: libcamera.so.0.0.1: cannot open shared object file: No such file or directory

Tried it with a Pi Zero 2 W, both 64bit and 32bit RPI OS Lite and a Pi4 with 64bit RPI OS Lite. Tried the release v0.20.2

Thanks for following up

madison8935 commented 1 year ago

~Hello, I'm getting this error with the latest container on a Pi 4B. I don't have the slightest clue as to how to fix it. I'm just following the main guide. No mention of having to build things from source. Fully patched and set up according to the guide. What's going on here?~

Figured it out.....Not sure why, but I ended up doing a full OS reinstall to get it working though. Not ideal, but I guess that was what I had to do.

Can you provide the Versions of your libcamera and rtsp-simple-server aswell as what raspberry and what OS your are using? I'm still stuck with this issue.

erikgranlund commented 1 year ago

Hey all,

I will preface the below to say I know very little about how Go works, so I apologize if I made a dumb and obvious error in the output I pasted below.

I am having the same issue @madison8935 is with the latest version (v0.20.2):

./rtsp-simple-server rtsp-simple-server.yml 
2022/12/07 13:19:06 INF rtsp-simple-server v0.20.2
2022/12/07 13:19:06 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/12/07 13:19:06 INF [RTMP] listener opened on :1935
2022/12/07 13:19:06 INF [HLS] listener opened on :8888
2022/12/07 13:19:06 INF [path myStream] [rpicamera source] started
/dev/shm/rtspss-embeddedexe-1670447946250311960: error while loading shared libraries: libcamera.so.0.0.1: cannot open shared object file: No such file or directory
2022/12/07 13:19:06 INF [path myStream] [rpicamera source] ERR: process exited unexpectedly

—-

I’m using a Pi Zero 1 with the 32 bit Debian Buster “lite” image from the Raspberry Pi Imager tool. I ran apt update and apt upgrade and ensured libcamera-apps was installed.

Here’s my output the find command above (I suspect my lib is called libcamera.so.0.0.2):

sudo find / -type f -name "libcamera*"
/var/lib/dpkg/info/libcamera0:armhf.md5sums
/var/lib/dpkg/info/libcamera-dev:armhf.list
/var/lib/dpkg/info/libcamera-dev:armhf.md5sums
/var/lib/dpkg/info/libcamera-apps.list
/var/lib/dpkg/info/libcamera0:armhf.list
/var/lib/dpkg/info/libcamera-tools.list
/var/lib/dpkg/info/libcamera0:armhf.triggers
/var/lib/dpkg/info/libcamera-apps.md5sums
/var/lib/dpkg/info/libcamera-tools.md5sums
/var/lib/dpkg/info/libcamera-apps.triggers
/var/lib/dpkg/info/libcamera0:armhf.shlibs
/var/cache/apt/archives/libcamera-tools_0~git20220826+3fad116f-1_armhf.deb
/usr/lib/arm-linux-gnueabihf/libcamera.so.0.0.2
/usr/lib/arm-linux-gnueabihf/libcamera-base.so.0.0.2
/usr/lib/arm-linux-gnueabihf/pkgconfig/libcamera-base.pc
/usr/lib/arm-linux-gnueabihf/pkgconfig/libcamera.pc
/usr/lib/arm-linux-gnueabihf/libcamera_app.so
/usr/bin/libcamera-vid
/usr/bin/libcamera-raw
/usr/bin/libcamera-still
/usr/bin/libcamera-hello
/usr/bin/libcamera-jpeg
/usr/include/libcamera/libcamera/libcamera.h 

Compiling the rpiCamera source seemed to work without a hitch:

~/rtsp-simple-server/internal/rpicamera/exe $ make -j2
g++ -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -std=c++17 $(pkg-config --cflags libcamera) -c camera.cpp -o camera.o
cc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c encoder.c -o encoder.o
cc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c main.c -o main.o
cc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c parameters.c -o parameters.o
cc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c roi.c -o roi.o
cc -Ofast -Werror -Wall -Wextra -Wno-unused-parameter -c sensor_mode.c -o sensor_mode.o
g++ -o exe camera.o encoder.o main.o parameters.o roi.o sensor_mode.o -s -pthread $(pkg-config --libs libcamera)

But I can’t seem to get the binaries to compile on my side (probably user error!)

~/rtsp-simple-server $ GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server -tags rpicamera
internal/rpicamera/rpicamera.go:7:2: package embed is not in GOROOT (/usr/lib/go-1.15/src/embed)

p.s. thank you for this project! It’s been really fun to play around with!

yllekz commented 1 year ago

To reply to both posts above, I think the issue is the project requires a 64-bit Pi OS installation. I think my issue was my prior install was a 32-bit Pi OS and one of the first requirements posted is to be on 64-bit.

erikgranlund commented 1 year ago

@yllekz I do not think that is the case — when I linked libcamera-base and libcamera to the older version to quickly check then rtsp-simple-server works fine.

/usr/lib/arm-linux-gnueabihf $ sudo ln -s libcamera-base.so.0.0.2 libcamera-base.so.0.0.1
/usr/lib/arm-linux-gnueabihf $ sudo ln -s libcamera.so.0.0.2 libcamera.so.0.0.1
~/Downloads $ ./rtsp-simple-server rtsp-simple-server.yml 
2022/12/07 15:32:20 INF rtsp-simple-server v0.20.2
2022/12/07 15:32:20 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/12/07 15:32:20 INF [RTMP] listener opened on :1935
2022/12/07 15:32:20 INF [HLS] listener opened on :8888
2022/12/07 15:32:20 INF [path myStream] [rpicamera source] started
[2:40:30.460478350] [2157]  INFO Camera camera_manager.cpp:299 libcamera v0.0.2+47-0684c373
[2:40:30.624136546] [2161]  WARN RPI raspberrypi.cpp:1306 Mismatch between Unicam and CamHelper for embedded data usage!
[2:40:30.630678474] [2161]  INFO RPI raspberrypi.cpp:1423 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media3 and ISP device /dev/media0
[2:40:30.637384400] [2157]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1080-YUV420
[2:40:30.641294357] [2161]  INFO RPI raspberrypi.cpp:803 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 1920x1080-SBGGR10_1X10 - Selected unicam format: 1920x1080-pBAA
2022/12/07 15:32:21 INF [path myStream] [rpicamera source] ready: 1 track (H264)
aler9 commented 1 year ago

one of the first requirements posted is to be on 64-bit.

no, both 64 bit and 32 bits are supported.

I am having the same issue @madison8935 is with the latest version (v0.20.2)

Raspberry Pi maintainers once again updated libcamera without notice, breaking compatibility with all existing software. This will be fixed (once again).

aler9 commented 1 year ago

The latest version (v0.20.3) is linked against libcamera 0.0.2 and also tries to use any available version that is installed on the machine.

Make sure to upgrade libcamera (sudo apt update && sudo apt install libcamera0).

If the problem arises again, please open a new issue.