どんな人が必要とする情報か
- v4l2rtspserverをgitからcloneしてmake中にlive555関連のlinkエラーが出て、直し方が分からない人。但し、記載の方法で直るとは限らない。あくまでも一例として。
- この対応方法はイマイチかも、と思ってます。こっちのほうが簡単やでぇというのがありましたら、コメント等で ご教授いただければ幸いです。
使用した開発環境&実行環境
- Raspberry Pi 4
- Raspberry Pi Imager v.1.6.2 で標準的なOSを64GBのSDカードに書き込んだ
- ラズパイ用フレキカメラv2.1
開発用opensslのインストール
$ sudo apt-get install libssl-dev
live555のインストール
Additional info on 2021/10/5
sudo apt-get install liblivemedia-dev
It would be OK instead of downloading tar.gz and build to use lib and .h files of liveMedia.
ダウンロード
http://www.live555.com/liveMedia/public/
から、最新のアーカイブをダウンロード。
私の評価時は live.2021.08.24.tar.gz = live555-latest.tar.gz でした。
ビルド
http://www.live555.com/liveMedia/#config-unix
に記載の手順でビルドする。
↑のサイトに
Some people (in particular, FreeBSD users) have reported that the GNU version of "make" - often called "gmake" - works better than their default, pre-installed version of "make". (In particular, you should try using "gmake" if you encounter linking problems with the "ar" command.)
…と書かれてるので、もしかしたら、以下の手順ではmakeよりもgmakeのほうがいいのかも。。。
genMakefilesコマンドのオプションは自分の環境に合わせて選ぶ。linuxで実行したが、armlinuxのほうが良かった?説?
$ tar -zxvf live.2021.08.24.tar.gz
$ cd live
$ ./genMakefiles linux
$ make
$ sudo make install
v4l2rtspserverのビルドと実行
linkエラーが出るまでの手順
$ sudo apt-get install cmake
$ sudo apt-get install subversion
$ cd ~/git
$ mkdir mpromonet
# cd mpromonet
$ git clone https://github.com/mpromonet/v4l2rtspserver.git
$ cd v4l2rtspserver
$ cmake .
$ make
この最後のmake中にlive555のモジュールが見つからない(undefined reference to ...)のリンクエラーが複数モジュールに対して表示される
linkエラーを回避する手順
- v4l2rtspserverインストールフォルダ以下の CMakeFiles/v4l2rtspserver.dir/link.txt を以下のように修正(コマンドライン文字列を短くし、ライブラリファイルの指定順を変更してる)
修正前 (環境によってディレクトリ名は変わる)
/usr/bin/c++ -L /usr/local/lib/openssl -rdynamic CMakeFiles/v4l2rtspserver.dir/main.cpp.o -o v4l2rtspserver -llog4cpp /usr/local/lib/libliveMedia.a /usr/local/lib/libUsageEnvironment.a /usr/local/lib/libBasicUsageEnvironment.a /usr/local/lib/libgroupsock.a liblibv4l2rtspserver.a libv4l2wrapper.a -pthread
修正後(テキストエディタなどで修正)
/usr/bin/c++ -L. -L/usr/local/lib -L/usr/local/openssl/3_1_0dev/lib -rdynamic CMakeFiles/v4l2rtspserver.dir/main.cpp.o -o v4l2rtspserver -pthread -llog4cpp -llibv4l2rtspserver -lv4l2wrapper -lssl -lcrypto -lliveMedia -lBasicUsageEnvironment -lgroupsock -lUsageEnvironment
再度 make 実行でリンクが通る。
実行エラーが出るまでの手順(人によっては出ないかも)
$ sudo v4l2rtspserver
v4l2rtspserver: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
実行エラーを回避する手順
- /etc/ld.so.conf.d/に以下のファイルを置く
# openssl configuration
/usr/local/openssl/3_1_0dev/lib
以下コマンドを実行
$ sudo ldconfig
再度実行
$ sudo v4l2rtspserver
それらしい実行状況表示があり、Win10PCのVLC Media Playerでストりーみいんぐ再生を見ることができた。
参考URL