kclyu / rpi-webrtc-streamer

This repo's objective is providing something like Web Cam server on the most popular Raspberry PI hardware. By integrating [WebRTC](https://webrtc.org/native-code/) and Raspberry PI, we can stream the Raspberry camera feed to browser or native client which talks WebRTC.
Other
617 stars 108 forks source link

Error when Building WebRTC native-code #98

Closed miguelwon closed 3 years ago

miguelwon commented 4 years ago

I'm getting the following error at step 3.2 of Building WebRTC native-code, and when executing gn gen out/arm_build:

mwon@mwon:/mwon_disk/disk2/raspberry/build-webrtc/src$ gn gen out/arm_build
ERROR at //third_party/BUILD.gn:30:21: Can't load input file.
    public_deps = [ "//third_party/libjpeg:libjpeg" ]
                    ^------------------------------
Unable to load:
  /mwon_disk/disk2/raspberry/build-webrtc/src/third_party/libjpeg/BUILD.gn
I also checked in the secondary tree for:
  /mwon_disk/disk2/raspberry/build-webrtc/src/build/secondary/third_party/libjpeg/BUILD.gn
kclyu commented 4 years ago

This is because there was a jpeg related commit in the WebRTC native code package. The jpeg patch has not been applied to the rws master yet.

Since then, the patch has been applied to the current local master, but there is a bug in the WebRTC native code package or a problem that an additional API has not been applied, so it operates only at a specific commit position.

To use the current master brach, please use the comit position indicated at https://github.com/kclyu/rpi-webrtc-streamer/commit/8ff2e5d6a92fdfd70b19d38def379b5833362467.

kclyu commented 4 years ago

@SourceCodeZone I think, i failed to make it clear. Rather than using the RWS commit mentioned at https://github.com/kclyu/rpi-webrtc-streamer/commit/8ff2e5d6a92fdfd70b19d38def379b5833362467, it meant moving the commit position of the WebRTC native code to that location and doing the build again.

cd ~/Workspace/webrtc/src
gclient sync -n -D -r 64f1f3f04edd945c8ae9f403f37ffb5cb6e7c14d
gclient sync
gn gen out/arm_build
ninja -C out/arm_build
SourceCodeZone commented 4 years ago

So do I need to run below command before running above command

cd ~/Workspace/webrtc
fetch --nohooks webrtc
gclient sync
git config branch.autosetupmerge always
git config branch.autosetuprebase always
cd src
git checkout master
kclyu commented 4 years ago

You need the WebRTC code package to go to a specific commit location, so it is correct to fetch native code at first.

kclyu commented 4 years ago

Anyway, jpeg or pulse related include error can be solved by adding libjpeg and libpulse to rpi_rootfs below. It will build normally up to RWS, but the current master does not work with the latest WebRTC native code.

cd ~/Workspace/rpi_rootfs
sudo ./build_rootfs.sh cmd "/usr/bin/apt install -y libjpeg9-dev libpulse-dev"
SourceCodeZone commented 4 years ago

Ok thanks for the valuable information. I have one more doubt, I have to access the rasberryPi camera publicly without port-forwarding, I found the webrtc can use in such a situation for peer to peer communication. Like my RPi will be in local network and a webserver is installed in Godaddy with html page whch should display the live feed from Rpi. Is this possible with rpi-webrtc-streamer

kclyu commented 4 years ago

@SourceCodeZone The content of the question is not related to this issue. In browser, WebRTC can be used as http in local network. However, in remote network (ie public network), you need to use https to use WebRTC.

SourceCodeZone commented 4 years ago

Sorry for asking anyway my doubt is clear, I have one more issue, the command ninja -C out/arm_build completed without error. But when I run the command

cd ~/Workspace/rpi-webrtc-streamer/src
make

Got following error.

Linking C executable cmTC_84429 /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_84429.dir/link.txt --verbose=1 /opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/user/Workspace/rpi_rootfs/rootfs -Wl,-rpath-link=/home/user/Workspace/rpi_rootfs/rootfs/lib/arm-linux-gnueabihf:/home/user/Workspace/rpi_rootfs/rootfs/usr/lib/arm-linux-gnueabihf -ldl -rdynamic CMakeFiles/cmTC_84429.dir/testCCompiler.c.o -o cmTC_84429 /home/user/Workspace/rpi_rootfs/tools/gcc-linaro-8.3.0-2019.03-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.27' not found (required by /home/user/Workspace/rpi_rootfs/tools/gcc-linaro-8.3.0-2019.03-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld) collect2: error: ld returned 1 exit status CMakeFiles/cmTC_84429.dir/build.make:103: recipe for target 'cmTC_84429' failed make[2]: [cmTC_84429] Error 1 make[2]: Leaving directory '/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp' Makefile:138: recipe for target 'cmTC_84429/fast' failed make[1]: [cmTC_84429/fast] Error 2 make[1]: Leaving directory '/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp'

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:180 (project)

-- Configuring incomplete, errors occurred! See also "/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeOutput.log". See also "/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeError.log". ude -I/opt/rpi_rootfs/rootfs/opt/vc/include/interface/mmal -I/opt/rpi_rootfs/rootfs/usr/include -I/home/user/Workspace/webrtc/src/third_party/abseil-cpp/ -c websocket_server.cc -o websocket_server.o In file included from websocket_server.h:42, from websocket_server.cc:37: websocket_server_internal.h:39:10: fatal error: libwebsockets.h: No such file or directory

include "libwebsockets.h"

      ^~~~~~~~~~~~~~~~~

compilation terminated. Makefile:96: recipe for target 'websocket_server.o' failed make: *** [websocket_server.o] Error 1

Edit:

I tried to install libwebsockets on rpi_rootfs by sudo ./build_rootfs.sh cmd "/usr/bin/apt install -y libwebsockets-dev " and the package installed, but when I run the make command got new errors.

websocket_server.cc:75:1: error: too many initializers for ‘lws_protocols’
 };
 ^
websocket_server.cc: In destructor ‘virtual LibWebSocketServer::~LibWebSocketServer()’:
websocket_server.cc:130:5: error: ‘lws_vhost_destroy’ was not declared in this scope
     lws_vhost_destroy(vhost_);
     ^~~~~~~~~~~~~~~~~
websocket_server.cc:130:5: note: suggested alternative: ‘lws_vhost_get’
     lws_vhost_destroy(vhost_);
     ^~~~~~~~~~~~~~~~~
     lws_vhost_get
websocket_server.cc: In member function ‘bool LibWebSocketServer::Init(int)’:
websocket_server.cc:203:11: error: ‘struct lws_context_creation_info’ has no member named ‘ws_ping_pong_interval’
     info_.ws_ping_pong_interval = 1;  // WebSocket Ping/Pong interval
           ^~~~~~~~~~~~~~~~~~~~~
Makefile:96: recipe for target 'websocket_server.o' failed
make: *** [websocket_server.o] Error 1
kclyu commented 4 years ago

libwebsockets used by rws uses the lib/libwebsockets-3.1.zip source file in rws repo. Be sure to delete libwebsockets-dev installed in rpi_rootfs.

SourceCodeZone commented 4 years ago

I remove it and run make again still having the first error.

kclyu commented 4 years ago

Is your OS not Ubuntu? Currently, it is not confirmed whether it works on Windows or Mac OS. It may be seen as an OS difference, but if you are using Ubuntu OS, check the result of the command below.

# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
# make -version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# cmake -version
cmake version 3.10.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
SourceCodeZone commented 4 years ago

Yes Ubuntu 16.04

# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

# make -versionmake -versionmake -versionmake -versionmake -versionmake -versionmake -versionmake -versionmake -versionmake -version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

#  cmake -version
cmake version 3.17.0-rc1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
kclyu commented 4 years ago

I think there is a problem building libwebsockets. Please do as below.

cd ~/Workspace/rpi-webrtc-streamer/lib
rm -fr libwebsockets
 ../mk/config_libwebsockets.sh /opt/rpi_rootfs
cd ../src
make

If the same problem persists, please check if there are any files related to libwebsockets in rpi_rootfs/rootfs.

cd ~/Workspace/rpi_rootfs/rootfs
sudo find . -name \*libwebsocket\*
SourceCodeZone commented 4 years ago

$../mk/config_libwebsockets.sh /opt/rpi_rootfs Give the output

start building libwebsockets library
-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc - broken
CMake Error at /usr/local/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make cmTC_9a232/fast && /usr/bin/make -f CMakeFiles/cmTC_9a232.dir/build.make CMakeFiles/cmTC_9a232.dir/build
    make[1]: Entering directory '/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_9a232.dir/testCCompiler.c.o
    /opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/user/Workspace/rpi_rootfs/rootfs -DBOOST_COROUTINES_NO_DEPRECATION_WARNING   -o CMakeFiles/cmTC_9a232.dir/testCCompiler.c.o   -c /home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_9a232
    /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9a232.dir/link.txt --verbose=1
    /opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/user/Workspace/rpi_rootfs/rootfs    -Wl,-rpath-link=/home/user/Workspace/rpi_rootfs/rootfs/lib/arm-linux-gnueabihf:/home/user/Workspace/rpi_rootfs/rootfs/usr/lib/arm-linux-gnueabihf -ldl  -rdynamic CMakeFiles/cmTC_9a232.dir/testCCompiler.c.o  -o cmTC_9a232 
    /home/user/Workspace/rpi_rootfs/tools/gcc-linaro-8.3.0-2019.03-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.27' not found (required by /home/user/Workspace/rpi_rootfs/tools/gcc-linaro-8.3.0-2019.03-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld)
    collect2: error: ld returned 1 exit status
    CMakeFiles/cmTC_9a232.dir/build.make:103: recipe for target 'cmTC_9a232' failed
    make[1]: *** [cmTC_9a232] Error 1
    make[1]: Leaving directory '/home/user/Workspace/rpi-webrtc-streamer/lib/libwebsockets/arm_build/CMakeFiles/CMakeTmp'
    Makefile:138: recipe for target 'cmTC_9a232/fast' failed
    make: *** [cmTC_9a232/fast] Error 2

Please not the error /lib/x86_64-linux-gnu/libc.so.6: versionGLIBC_2.27'` not found above, could it be the problem.

And the command $sudo find . -name \*libwebsocket\*

./var/lib/dpkg/info/libwebsockets8:armhf.symbols
./var/lib/dpkg/info/libwebsockets8:armhf.triggers
./var/lib/dpkg/info/libwebsockets8:armhf.list
./var/lib/dpkg/info/libwebsockets8:armhf.md5sums
./var/lib/dpkg/info/libwebsockets8:armhf.shlibs
./usr/share/doc/libwebsockets8
./usr/share/lintian/overrides/libwebsockets8
./usr/lib/arm-linux-gnueabihf/libwebsockets.so.8

I am using latest image for rootfs 2020-02-13-raspbian-buster.img could that be the problem.

kclyu commented 4 years ago

The problem is GLIBC_2.27. I think you should upgrade as Ubuntu 18.04.

SourceCodeZone commented 4 years ago

At the moment I couldn't, my server and most of the project working on Ubuntu 16.04, is there any way to GLIBC_2.27 in 16.04. Also one doubt the GLIBC_2.27 problem is in cross compiler or in my Ubuntu OS

kclyu commented 4 years ago

you should find and install the cross compiler for raspberry pi for Ubuntu 16.04. For now, you can find it at https://github.com/abhiTronix/raspberry-pi-cross-compilers or by googling.

kclyu commented 4 years ago

you need to add libpulse and libjpeg to rpi_rootfs as below.

cd ~/Workspace/rpi_rootfs
sudo ./build_rootfs.sh cmd "/usr/bin/apt install -y libjpeg9-dev libpulse-dev"

Please update the native code to the latest version as shown below.

cd ~/Workspace/webrtc/src
git pull
gclient sync

Also update rws to the latest master and build native code and rws as shown below.

cd rpi-webrtc-streamer
git pull
cp misc/webrtc_arm_build_args.gn ~/Workspace/webrtc/src/out/arm_build/args.gn
cd ~/Workspace/webrtc/src
gn clean out/arm_build
gn gen out/arm_build
ninja -C out/arm_build
cd ~/Workspace/rpi-webrtc-streamer/src
make clean
make
jasonmnemonic commented 2 years ago

Anyway, jpeg or pulse related include error can be solved by adding libjpeg and libpulse to rpi_rootfs below. It will build normally up to RWS, but the current master does not work with the latest WebRTC native code.

cd ~/Workspace/rpi_rootfs
sudo ./build_rootfs.sh cmd "/usr/bin/apt install -y libjpeg9-dev libpulse-dev"

Hi kclyu.

I know this thread is old and it is for gclient sync -n -D -r 435fb9ad06a2fd20b31fae4eda4e2f5bfe32d293 where you have been teaching others on how to resolve

ERROR at //third_party/BUILD.gn:30:21: Can't load input file.
    public_deps = [ "//third_party/libjpeg:libjpeg" ]
                    ^------------------------------
Unable to load:
  /home/teddybear/Workspace/webrtc/src/third_party/libjpeg/BUILD.gn
I also checked in the secondary tree for:
  /home/teddybear/Workspace/webrtc/src/build/secondary/third_party/libjpeg/BUILD.gn

I have the same problem as I tried to build webrtc 435fb9ad06a2fd20b31fae4eda4e2f5bfe32d293.

I can successfully build gclient sync -n -D -r 64f1f3f04edd945c8ae9f403f37ffb5cb6e7c14d and also also rws v0.74. This is a very good stuff that you are doing for the community. As I can understand more, I will also try to help you :-)

Now, I have pulled your latest rws 435fb9ad06a2fd20b31fae4eda4e2f5bfe32d293 and webrtc 130e0310108017d32e22377306b0d02ac21d3cc6 where I have been building and have problems so I am back-tracking a bit until I saw this thread. At the moment, I am trying to build webrtc 435fb9ad06a2fd20b31fae4eda4e2f5bfe32d293 so just like what you teach here.

So I have same problem but I run sudo ./build_rootfs.sh run "/usr/bin/apt install -y libjpeg9-dev libpulse-dev" and not cmd. If I did cmd, I get

command not found : cmd
Usage: ./build_rootfs.sh command [options]
  command: 
    download : download latest RaspiOS image
    create [image file]: 
      [image file]: raspi OS image zip/img file
    update : run apt update & full-upgrade & autoremove in rootfs
    run [command]: run raspberry pi command in rootfs

With run, it is successful and I think it installs into ~/Workspace/rpi_rootfs/rootfs/lib and not onto my local Ubuntu 20.04? The output of the successful command is:

Getting Sudo
CMD: /usr/bin/apt install -y libjpeg9-dev libpulse-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libjpeg9-dev is already the newest version (1:9b-1).
libpulse-dev is already the newest version (12.2-4+deb10u1+rpi3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

My webrtc/src/out/arm_build/args.gn is:

is_official_build=false
is_debug=true

arm_fpu="neon"
arm_use_neon=false
arm_optionally_use_neon=false
rtc_build_with_neon=false

When I run gn gen out/arm_build, I get the error message above when I started writing this post; see above on ERROR at //third_party/BUILD.gn:30:21: Can't load input file.

Any ideas?

Help please. Thank you. :+1: :-)

EDIT: back reference to https://github.com/kclyu/rpi-webrtc-streamer/issues/124#issuecomment-1094679197 to make it easier to find stuff.