ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.75k stars 5.28k forks source link

SRS server doesn't compile on respberrypi 4B Debian 10 #3873

Open DCZYewen opened 7 months ago

DCZYewen commented 7 months ago

Describe the bug SRS server doesn't compile on respberrypi 4B Debian 10

Version Newest git clone

To Reproduce

/usr/bin/ld: core.cpp:(.text+0x135dc): undefined reference to `__atomic_load_8'

``` root@rpitx:/home/pi/srs/trunk# make Build the SRS server, JOBS= --jobs=4, FORCE_MAKE_JOBS=YES make --jobs=4 -f ./objs/Makefile srs make[1]: Entering directory '/home/pi/srs/trunk' g++ -o ./objs/srs ./objs/src/core/srs_core.o ./objs/src/core/srs_core_version.o ./objs/src/core/srs_core_version5.o ./objs/src/core/srs_core_autofree.o ./objs/src/core/srs_core_performance.o ./objs/src/core/srs_core_time.o ./objs/src/core/srs_core_platform.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_ps.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_kbps.o ./objs/src/kernel/srs_kernel_rtc_rtp.o ./objs/src/kernel/srs_kernel_rtc_rtcp.o ./objs/src/protocol/srs_protocol_amf0.o ./objs/src/protocol/srs_protocol_io.o ./objs/src/protocol/srs_protocol_conn.o ./objs/src/protocol/srs_protocol_rtmp_handshake.o ./objs/src/protocol/srs_protocol_rtmp_stack.o ./objs/src/protocol/srs_protocol_utility.o ./objs/src/protocol/srs_protocol_rtmp_msg_array.o ./objs/src/protocol/srs_protocol_stream.o ./objs/src/protocol/srs_protocol_raw_avc.o ./objs/src/protocol/srs_protocol_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_protocol_log.o ./objs/src/protocol/srs_protocol_st.o ./objs/src/protocol/srs_protocol_http_client.o ./objs/src/protocol/srs_protocol_http_conn.o ./objs/src/protocol/srs_protocol_rtmp_conn.o ./objs/src/protocol/srs_protocol_protobuf.o ./objs/src/protocol/srs_protocol_srt.o ./objs/src/protocol/srs_protocol_rtc_stun.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_st.o ./objs/src/app/srs_app_log.o ./objs/src/app/srs_app_config.o ./objs/src/app/srs_app_stream_bridge.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_listener.o ./objs/src/app/srs_app_async_call.o ./objs/src/app/srs_app_caster_flv.o ./objs/src/app/srs_app_latest_version.o ./objs/src/app/srs_app_uuid.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_threads.o ./objs/src/app/srs_app_srt_server.o ./objs/src/app/srs_app_srt_listener.o ./objs/src/app/srs_app_srt_conn.o ./objs/src/app/srs_app_srt_utility.o ./objs/src/app/srs_app_srt_source.o ./objs/src/app/srs_app_rtc_conn.o ./objs/src/app/srs_app_rtc_dtls.o ./objs/src/app/srs_app_rtc_sdp.o ./objs/src/app/srs_app_rtc_network.o ./objs/src/app/srs_app_rtc_queue.o ./objs/src/app/srs_app_rtc_server.o ./objs/src/app/srs_app_rtc_source.o ./objs/src/app/srs_app_rtc_api.o ./objs/src/app/srs_app_rtc_codec.o ./objs/src/main/srs_main_server.o ./objs/st/libst.a ./objs/openssl/lib/libssl.a ./objs/openssl/lib/libcrypto.a ./objs/srtp2/lib/libsrtp2.a ./objs/ffmpeg/lib/libavcodec.a ./objs/ffmpeg/lib/libswresample.a ./objs/ffmpeg/lib/libavutil.a ./objs/opus/lib/libopus.a ./objs/srt/lib/libsrt.a -ldl -lpthread -lrt -rdynamic /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::sendCtrl(srt::UDTMessageType, int const*, void*, int) [clone .constprop.448]': core.cpp:(.text+0x23c): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::construct()': core.cpp:(.text+0x3b4): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::open()': core.cpp:(.text+0x8bc): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x900): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x940): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o):core.cpp:(.text+0x96c): more undefined references to `__atomic_store_8' follow /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::bstats(CBytePerfMon*, bool, bool)': core.cpp:(.text+0x29ec): undefined reference to `__atomic_load_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::checkExpTimer(srt::sync::TimePoint const&, int)': core.cpp:(.text+0x39f0): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x3a18): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x3b60): undefined reference to `__atomic_load_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::updateCC(srt::ETransmissionEvent, srt::EventVariant)': core.cpp:(.text+0xa8b0): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::setupCC()': core.cpp:(.text+0xb780): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0xb7c0): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0xb7fc): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0xb824): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o):core.cpp:(.text+0xca2c): more undefined references to `__atomic_store_8' follow /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::checkACKTimer(srt::sync::TimePoint const&)': core.cpp:(.text+0xcf64): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0xd068): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::checkNAKTimer(srt::sync::TimePoint const&) [clone .part.288]': core.cpp:(.text+0xd168): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0xd1e4): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::checkTimers()': core.cpp:(.text+0xd32c): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0xd354): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0xd398): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0xd4fc): undefined reference to `__atomic_load_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::packData(srt::CPacket&, srt::sync::TimePoint&, srt::sockaddr_any&)': core.cpp:(.text+0x13484): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x135dc): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x13604): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x1361c): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x13704): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x13738): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x137d4): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x137fc): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x1382c): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x1384c): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::processData(srt::CUnit*)': core.cpp:(.text+0x181d4): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x1898c): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::processConnectResponse(srt::CPacket const&, srt::CUDTException*)': core.cpp:(.text+0x1ce3c): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o):core.cpp:(.text+0x1cfbc): more undefined references to `__atomic_store_8' follow /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::startConnect(srt::sockaddr_any const&, int)': core.cpp:(.text+0x1eaa0): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x1eb00): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::processCtrlHS(srt::CPacket const&)': core.cpp:(.text+0x1ff14): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::CUDT::processCtrl(srt::CPacket const&)': core.cpp:(.text+0x2000c): undefined reference to `__atomic_store_8' /usr/bin/ld: core.cpp:(.text+0x201ac): undefined reference to `__atomic_load_8' /usr/bin/ld: core.cpp:(.text+0x20208): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(core.cpp.o): in function `srt::sync::AtomicClock::operator=(srt::sync::TimePoint const&)': core.cpp:(.text._ZN3srt4sync11AtomicClockINS0_12steady_clockEEaSERKNS0_9TimePointIS2_EE[_ZN3srt4sync11AtomicClockINS0_12steady_clockEEaSERKNS0_9TimePointIS2_EE]+0x24): undefined reference to `__atomic_store_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(queue.cpp.o): in function `srt::CRendezvousQueue::updateConnStatus(srt::EReadStatus, srt::EConnectStatus, srt::CUnit*)': queue.cpp:(.text+0x346c): undefined reference to `__atomic_load_8' /usr/bin/ld: ./objs/srt/lib/libsrt.a(queue.cpp.o): in function `srt::CRendezvousQueue::qualifyToHandle(srt::EReadStatus, srt::EConnectStatus, int, std::vector >&, std::vector >&)': queue.cpp:(.text+0x3e8c): undefined reference to `__atomic_load_8' collect2: error: ld returned 1 exit status make[1]: *** [objs/Makefile:756: objs/srs] Error 1 make[1]: Leaving directory '/home/pi/srs/trunk' make: *** [Makefile:98: server] Error 2 ```

DCZYewen commented 7 months ago

The reason is command make --jobs=4 -f ./objs/Makefile srs trying to link the program when error encounters. I do a little workaround made the compile goes.

DCZYewen commented 7 months ago

The build summary: +------------------------------------------------------------------------------------ For SRS benchmark, gperf, gprof and valgrind, please read: https://www.jianshu.com/p/6d4a89359352 +------------------------------------------------------------------------------------ |The main server usage: ./objs/srs -c conf/srs.conf, start the srs server | About HLS, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls | About DVR, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr | About SSL, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/rtmp-handshake | About transcoding, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/ffmpeg | About ingester, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/ingest | About http-callback, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-callback | Aoubt http-server, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-server | About http-api, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-api | About stream-caster, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/streamer | (Disabled) About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2 +------------------------------------------------------------------------------------ binaries, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/install You can: ./objs/srs -c conf/srs.conf to start the srs server, with config conf/srs.conf.

DCZYewen commented 7 months ago

So the problem is the autoconf seemed missed the dependency of libatomic add -latomic in the configure file did fix the problem I recommend that adding SrsLinkOptions="${SrsLinkOptions} -latomic"; on configure file line 210. Then restart the configure mission. then make command did successful.

winlinvip commented 7 months ago

Does the SRT library depend on -latomic? If we use ./configure --srt=off, can it succeed? We need to know specifically which library depends on -latomic, rather than directly adding this option to solve the problem.

Not only do we need to know how to do it, but we also need to understand why.

TRANS_BY_GPT4

DCZYewen commented 7 months ago

On the newset version of libsrt I found a note in srt/srtcore/atomic.h which trying to warp the atomic header in a uniform statis. It says:

   // NOTE: GCC compiler built-ins for atomic operations are pure
   //    compiler extensions prior to GCC-4.7 and were grouped into the
   //    the __sync_* family of functions. GCC-4.7, both the c++11 and C11
   //    standards had been finalized, and GCC updated their built-ins to
   //    better reflect the new memory model and the new functions grouped
   //    into the __atomic_* family. Also the memory models were defined
   //    differently, than in pre 4.7.
   // TODO: PORT to the pre GCC-4.7 __sync_* intrinsics. In the meantime use
   //    the POSIX Mutex Implementation.

So on raspberry piOS 10, gcc version is gcc8.3. as it said, typically all versions later than gcc4.7 atomic features were implemented as __atomic_* function families. which is the symbol ported out from libatomic.so. Tks

winlinvip commented 7 months ago

Thanks for the feedback.

A suitable solution would be to try and detect the environment. If there is a need to link the atomic library, then add this link option.

Could you consider submitting a Patch to SRS?

TRANS_BY_GPT4

lizhiwen19900709 commented 3 months ago

So the problem is the autoconf seemed missed the dependency of libatomic add -latomic in the configure file did fix the problem I recommend that adding SrsLinkOptions="${SrsLinkOptions} -latomic"; on configure file line 210. Then restart the configure mission. then make command did successful.

The problem persists after addition image

Linux raspberrypi 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l GNU/Linux

winlinvip commented 3 months ago

As a workaround, you can set the ldflags, which is passed to linker:

./configure -h |grep ldflags
  --extra-ldflags=<ELDFLAGS> Set ELDFLAGS as LDFLAGS.

For example:

./configure --extra-ldflags="-latomic"

If it's a common flags for RaspberryPI, I think it's acceptable to do this automatically.