Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC: Support ARM Environment Compilation #1685

Closed
sevenzoe opened this issue Apr 1, 2020 · 11 comments
Closed

WebRTC: Support ARM Environment Compilation #1685

sevenzoe opened this issue Apr 1, 2020 · 11 comments
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@sevenzoe
Copy link

sevenzoe commented Apr 1, 2020

On Ubuntu, cross-compile SRS using Docker.
There were issues with cross-compiling for ARM on the develop branch, but cross-compiling for ARM on the release4.0 branch was successful.

Please describe the issue you encountered.

  1. SRS version: develop version
  2. The log of SRS is as follows:
    arm-linux-gnueabihf-g++ -o objs/srs objs/src/core/srs_core.o objs/src/core/srs_core_version4.o objs/src/core/srs_core_autofree.o objs/src/core/srs_core_performance.o objs/src/core/srs_core_mem_watch.o objs/src/core/srs_core_time.o objs/src/kernel/srs_kernel_error.o objs/src/kernel/srs_kernel_log.o objs/src/kernel/srs_kernel_buffer.o objs/src/kernel/srs_kernel_utility.o objs/src/kernel/srs_kernel_flv.o objs/src/kernel/srs_kernel_codec.o objs/src/kernel/srs_kernel_io.o objs/src/kernel/srs_kernel_consts.o objs/src/kernel/srs_kernel_aac.o objs/src/kernel/srs_kernel_mp3.o objs/src/kernel/srs_kernel_ts.o objs/src/kernel/srs_kernel_stream.o objs/src/kernel/srs_kernel_balance.o objs/src/kernel/srs_kernel_mp4.o objs/src/kernel/srs_kernel_file.o objs/src/kernel/srs_kernel_rtp.o objs/src/protocol/srs_protocol_amf0.o objs/src/protocol/srs_protocol_io.o objs/src/protocol/srs_rtmp_stack.o objs/src/protocol/srs_rtmp_handshake.o objs/src/protocol/srs_protocol_utility.o objs/src/protocol/srs_rtmp_msg_array.o objs/src/protocol/srs_protocol_stream.o objs/src/protocol/srs_raw_avc.o objs/src/protocol/srs_rtsp_stack.o objs/src/protocol/srs_sip_stack.o objs/src/protocol/srs_http_stack.o objs/src/protocol/srs_protocol_kbps.o objs/src/protocol/srs_protocol_json.o objs/src/protocol/srs_protocol_format.o objs/src/protocol/srs_stun_stack.o objs/src/service/srs_service_log.o objs/src/service/srs_service_st.o objs/src/service/srs_service_http_client.o objs/src/service/srs_service_http_conn.o objs/src/service/srs_service_rtmp_conn.o objs/src/service/srs_service_utility.o objs/src/service/srs_service_conn.o objs/src/app/srs_app_server.o objs/src/app/srs_app_conn.o objs/src/app/srs_app_rtmp_conn.o objs/src/app/srs_app_source.o objs/src/app/srs_app_refer.o objs/src/app/srs_app_hls.o objs/src/app/srs_app_forward.o objs/src/app/srs_app_encoder.o objs/src/app/srs_app_http_stream.o objs/src/app/srs_app_thread.o objs/src/app/srs_app_bandwidth.o objs/src/app/srs_app_st.o objs/src/app/srs_app_log.o objs/src/app/srs_app_config.o objs/src/app/srs_app_pithy_print.o objs/src/app/srs_app_reload.o objs/src/app/srs_app_http_api.o objs/src/app/srs_app_http_conn.o objs/src/app/srs_app_http_hooks.o objs/src/app/srs_app_ingest.o objs/src/app/srs_app_ffmpeg.o objs/src/app/srs_app_utility.o objs/src/app/srs_app_edge.o objs/src/app/srs_app_heartbeat.o objs/src/app/srs_app_empty.o objs/src/app/srs_app_http_client.o objs/src/app/srs_app_http_static.o objs/src/app/srs_app_recv_thread.o objs/src/app/srs_app_security.o objs/src/app/srs_app_statistic.o objs/src/app/srs_app_hds.o objs/src/app/srs_app_mpegts_udp.o objs/src/app/srs_app_rtsp.o objs/src/app/srs_app_listener.o objs/src/app/srs_app_async_call.o objs/src/app/srs_app_caster_flv.o objs/src/app/srs_app_process.o objs/src/app/srs_app_ng_exec.o objs/src/app/srs_app_hourglass.o objs/src/app/srs_app_dash.o objs/src/app/srs_app_fragment.o objs/src/app/srs_app_dvr.o objs/src/app/srs_app_coworkers.o objs/src/app/srs_app_hybrid.o objs/src/app/srs_app_rtc.o objs/src/app/srs_app_rtc_conn.o objs/src/app/srs_app_dtls.o objs/src/app/srs_app_audio_recode.o objs/src/app/srs_app_sdp.o objs/src/main/srs_main_server.o objs/st/libst.a objs/openssl/lib/libssl.a objs/openssl/lib/libcrypto.a objs/ffmpeg/lib/libavcodec.a objs/ffmpeg/lib/libswresample.a objs/ffmpeg/lib/libavutil.a objs/opus/lib/libopus.a objs/srtp2/lib/libsrtp2.a -ldl -lpthread -static
    objs/ffmpeg/lib/libavcodec.a: error adding symbols: File format not recognized
    collect2: error: ld returned 1 exit status
    objs/Makefile:519: recipe for target 'objs/srs' failed
    make[2]: *** [objs/srs] Error 1
    make[2]: Leaving directory '/tmp/srs/trunk'
    Makefile:82: recipe for target 'server' failed
    make[1]: *** [server] Error 2
    make[1]: Leaving directory '/tmp/srs/trunk'
    Makefile:10: recipe for target 'default' failed
    make: *** [default] Error 2

**Replay**

**How to replay bug?**

> Steps to reproduce the bug

1. get  code

git clone https://github.com/ossrs/srs.git && cd srs
git checkout remotes/origin/develop



2. get docker

sudo docker pull registry.cn-hangzhou.aliyuncs.com/ossrs/srs:ubuntu16



3. enter docker

sudo docker run -it -v `pwd`:/tmp/srs -w /tmp/srs/trunk registry.cn-hangzhou.aliyuncs.com/ossrs/srs:ubuntu16 bash



4. install the toolchain

apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
apt-get install -y --force-yes nasm



5. build

./configure --arm --static --cc=arm-linux-gnueabihf-gcc --cxx=arm-linux-gnueabihf-g++ --ar=arm-linux-gnueabihf-ar --ld=arm-linux-gnueabihf-ld --randlib=arm-linux-gnueabihf-randlib && make

**Expect**

> Expected behavior

**Please describe your expectation**

> Describe what you expect to happen

`TRANS_BY_GPT3`
@sevenzoe
Copy link
Author

sevenzoe commented Apr 1, 2020

I don't know if it's a problem with my environment.

lsb_release -a :

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

uname -a :

Linux ydx-desktop 4.15.0-88-generic #88~16.04.1-Ubuntu SMP Wed Feb 12 04:19:15 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Apr 1, 2020

I will make the change to automatically disable RTC during cross-compilation.
Also, I suggest you use 3.0 release instead of develop as it is prone to issues.

TRANS_BY_GPT3

@sevenzoe
Copy link
Author

sevenzoe commented Apr 1, 2020

I want an ARM version of SRS with WebRTC functionality, author, do you have any methods or ideas to solve it?

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Apr 1, 2020

In theory, it can be done by specifying the cross-compiler when compiling FFMPEG.

TRANS_BY_GPT3

@winlinvip winlinvip reopened this Apr 1, 2020
@winlinvip winlinvip added the Bug It might be a bug. label Apr 1, 2020
@winlinvip winlinvip added this to the SRS 4.0 release milestone Apr 1, 2020
@winlinvip
Copy link
Member

winlinvip commented Apr 1, 2020

@sevenzoe Can you handle it yourself?

TRANS_BY_GPT3

@sevenzoe
Copy link
Author

sevenzoe commented Apr 1, 2020

@winlinvip Yourself? Not much confidence, author.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Apr 1, 2020

./configure --cc=xxx-cc sets the variable SRS_TOOL_CC by externally specifying the compiler. This variable can be specified during compilation, for example, st is:

make  CC=${SRS_TOOL_CC}

If you can't figure it out, just wait and see if someone more skilled comes along.

TRANS_BY_GPT3

@sevenzoe
Copy link
Author

sevenzoe commented Apr 1, 2020

@winlinvip Hmm, wait a moment, I believe it's possible, author-sama

TRANS_BY_GPT3

@liuguang
Copy link

liuguang commented Apr 4, 2020

Switch to 608f3d0 and apply the patch attached.
git am 0001-fix-for-cross-build-with-arm-on-ubuntu16.patch
cd srs/trunk
./configure --arm --static --cc=arm-linux-gnueabihf-gcc --cxx=arm-linux-gnueabihf-g++ --ar=arm-linux-gnueabihf-ar --ld=arm-linux-gnueabihf-ld --randlib=arm-linux-gnueabihf-randlib && make

It can be cross-compiled on Ubuntu 16.
0001-fix-for-cross-build-with-arm-on-ubuntu16.zip

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented May 25, 2020

@liuguang 👍 I will find time to look at this patch and see if it can be merged.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Jun 20, 2021

Fixed

For cross-compiling:
Make sure to maintain the markdown structure.

  • openssl is a platform-specific tool:
    Make sure to maintain the markdown structure.
./Configure linux-armv4 linux-aarch64
  • libsrtp and libopus are host-specific:
    Make sure to maintain the markdown structure.
--host=HOST       cross-compile to build programs to run on HOST [BUILD]
  • FFmpeg is parameters and prefix:
    Make sure to maintain the markdown structure.
  --arch=ARCH              select architecture [arm, aarch64]
  --enable-cross-compile   assume a cross-compiler is used
  --target-os=OS           compiler targets OS []
  --cross-prefix=PREFIX    use PREFIX for compilation tools []

Usage:

root@c19bb908f5aa:/srs# uname -a
Linux c19bb908f5aa 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 armv7l armv7l armv7l GNU/Linux
root@c19bb908f5aa:/srs# 
root@c19bb908f5aa:/srs# 
root@c19bb908f5aa:/srs# ldd objs/srs
	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xfe7ae000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xfe78a000)
	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xfe774000)
	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xfe661000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xfe5e9000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xfe5c0000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xfe4d2000)
	/lib/ld-linux-armhf.so.3 (0xfefc7000)
root@c19bb908f5aa:/srs# 
root@c19bb908f5aa:/srs# ./objs/srs -v
4.0.128
root@c19bb908f5aa:/srs# 

TRANS_BY_GPT3

@winlinvip winlinvip changed the title develop分支,ARM交叉编译出现问题,release4.0分支,ARM交叉编译通过 WebRTC: 支持ARM环境编译 Sep 4, 2021
@winlinvip winlinvip self-assigned this Sep 4, 2021
@winlinvip winlinvip changed the title WebRTC: 支持ARM环境编译 WebRTC: Support ARM Environment Compilation Jul 27, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

3 participants