Need help from meson expert

Hello @nazar-pc , Jose and Inaki advised to connect to you. I have made an attempt to upgrade mediasoup from c++11 to C++14, as I desperately want to have auto args in lambda expressions in the event emitter callbacks. In my project with Cmake everything was fine but within mediasoup i am having issues.

Th i get this error on linking phase:
[7/7] Linking target mediasoup-worker
FAILED: mediasoup-worker
c++ -o mediasoup-worker mediasoup-worker.p/src_lib.cpp.o mediasoup-worker.p/src_DepLibSRTP.cpp.o mediasoup-worker.p/src_DepLibUV.cpp.o mediasoup-worker.p/src_DepLibWebRTC.cpp.o mediasoup-worker.p/src_DepOpenSSL.cpp.o mediasoup-worker.p/src_DepUsrSCTP.cpp.o mediasoup-worker.p/src_Logger.cpp.o mediasoup-worker.p/src_MediaSoupErrors.cpp.o mediasoup-worker.p/src_Settings.cpp.o mediasoup-worker.p/src_Worker.cpp.o mediasoup-worker.p/src_ChannelMessageRegistrator.cpp.o mediasoup-worker.p/src_Utils_Crypto.cpp.o mediasoup-worker.p/src_Utils_File.cpp.o mediasoup-worker.p/src_Utils_IP.cpp.o mediasoup-worker.p/src_Utils_String.cpp.o mediasoup-worker.p/src_handles_SignalsHandler.cpp.o mediasoup-worker.p/src_handles_TcpConnectionHandler.cpp.o mediasoup-worker.p/src_handles_TcpServerHandler.cpp.o mediasoup-worker.p/src_handles_Timer.cpp.o mediasoup-worker.p/src_handles_UdpSocketHandler.cpp.o mediasoup-worker.p/src_handles_UnixStreamSocket.cpp.o mediasoup-worker.p/src_Channel_ChannelNotifier.cpp.o mediasoup-worker.p/src_Channel_ChannelRequest.cpp.o mediasoup-worker.p/src_Channel_ChannelSocket.cpp.o mediasoup-worker.p/src_PayloadChannel_PayloadChannelNotification.cpp.o mediasoup-worker.p/src_PayloadChannel_PayloadChannelNotifier.cpp.o mediasoup-worker.p/src_PayloadChannel_PayloadChannelRequest.cpp.o mediasoup-worker.p/src_PayloadChannel_PayloadChannelSocket.cpp.o mediasoup-worker.p/src_RTC_ActiveSpeakerObserver.cpp.o mediasoup-worker.p/src_RTC_AudioLevelObserver.cpp.o mediasoup-worker.p/src_RTC_Consumer.cpp.o mediasoup-worker.p/src_RTC_DataConsumer.cpp.o mediasoup-worker.p/src_RTC_DataProducer.cpp.o mediasoup-worker.p/src_RTC_DirectTransport.cpp.o mediasoup-worker.p/src_RTC_DtlsTransport.cpp.o mediasoup-worker.p/src_RTC_IceCandidate.cpp.o mediasoup-worker.p/src_RTC_IceServer.cpp.o mediasoup-worker.p/src_RTC_KeyFrameRequestManager.cpp.o mediasoup-worker.p/src_RTC_NackGenerator.cpp.o mediasoup-worker.p/src_RTC_PipeConsumer.cpp.o mediasoup-worker.p/src_RTC_PipeTransport.cpp.o mediasoup-worker.p/src_RTC_PlainTransport.cpp.o mediasoup-worker.p/src_RTC_PortManager.cpp.o mediasoup-worker.p/src_RTC_Producer.cpp.o mediasoup-worker.p/src_RTC_RateCalculator.cpp.o mediasoup-worker.p/src_RTC_Router.cpp.o mediasoup-worker.p/src_RTC_RtpListener.cpp.o mediasoup-worker.p/src_RTC_RtpObserver.cpp.o mediasoup-worker.p/src_RTC_RtpPacket.cpp.o mediasoup-worker.p/src_RTC_RtpProbationGenerator.cpp.o mediasoup-worker.p/src_RTC_RtpStream.cpp.o mediasoup-worker.p/src_RTC_RtpStreamRecv.cpp.o mediasoup-worker.p/src_RTC_RtpStreamSend.cpp.o mediasoup-worker.p/src_RTC_RtxStream.cpp.o mediasoup-worker.p/src_RTC_SctpAssociation.cpp.o mediasoup-worker.p/src_RTC_SctpListener.cpp.o mediasoup-worker.p/src_RTC_SenderBandwidthEstimator.cpp.o mediasoup-worker.p/src_RTC_SeqManager.cpp.o mediasoup-worker.p/src_RTC_Shared.cpp.o mediasoup-worker.p/src_RTC_SimpleConsumer.cpp.o mediasoup-worker.p/src_RTC_SimulcastConsumer.cpp.o mediasoup-worker.p/src_RTC_SrtpSession.cpp.o mediasoup-worker.p/src_RTC_StunPacket.cpp.o mediasoup-worker.p/src_RTC_SvcConsumer.cpp.o mediasoup-worker.p/src_RTC_TcpConnection.cpp.o mediasoup-worker.p/src_RTC_TcpServer.cpp.o mediasoup-worker.p/src_RTC_Transport.cpp.o mediasoup-worker.p/src_RTC_TransportCongestionControlClient.cpp.o mediasoup-worker.p/src_RTC_TransportCongestionControlServer.cpp.o mediasoup-worker.p/src_RTC_TransportTuple.cpp.o mediasoup-worker.p/src_RTC_TrendCalculator.cpp.o mediasoup-worker.p/src_RTC_UdpSocket.cpp.o mediasoup-worker.p/src_RTC_WebRtcServer.cpp.o mediasoup-worker.p/src_RTC_WebRtcTransport.cpp.o mediasoup-worker.p/src_RTC_Codecs_H264.cpp.o mediasoup-worker.p/src_RTC_Codecs_H264_SVC.cpp.o mediasoup-worker.p/src_RTC_Codecs_VP8.cpp.o mediasoup-worker.p/src_RTC_Codecs_VP9.cpp.o mediasoup-worker.p/src_RTC_Codecs_Opus.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_Media.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_Parameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtcpFeedback.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtcpParameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpCodecMimeType.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpCodecParameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpEncodingParameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpHeaderExtensionParameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpHeaderExtensionUri.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpParameters.cpp.o mediasoup-worker.p/src_RTC_RtpDictionaries_RtpRtxParameters.cpp.o mediasoup-worker.p/src_RTC_SctpDictionaries_SctpStreamParameters.cpp.o mediasoup-worker.p/src_RTC_RTCP_Packet.cpp.o mediasoup-worker.p/src_RTC_RTCP_CompoundPacket.cpp.o mediasoup-worker.p/src_RTC_RTCP_SenderReport.cpp.o mediasoup-worker.p/src_RTC_RTCP_ReceiverReport.cpp.o mediasoup-worker.p/src_RTC_RTCP_Sdes.cpp.o mediasoup-worker.p/src_RTC_RTCP_Bye.cpp.o mediasoup-worker.p/src_RTC_RTCP_Feedback.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPs.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtp.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpNack.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpTmmb.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpSrReq.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpTllei.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpEcn.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackRtpTransport.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsPli.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsSli.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsRpsi.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsFir.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsTst.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsVbcm.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsLei.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsAfb.cpp.o mediasoup-worker.p/src_RTC_RTCP_FeedbackPsRemb.cpp.o mediasoup-worker.p/src_RTC_RTCP_XR.cpp.o mediasoup-worker.p/src_RTC_RTCP_XrDelaySinceLastRr.cpp.o mediasoup-worker.p/src_RTC_RTCP_XrReceiverReferenceTime.cpp.o mediasoup-worker.p/src_main.cpp.o -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error subprojects/abseil-cpp-20211102.0/libabsl_container.a subprojects/abseil-cpp-20211102.0/libabsl_base.a subprojects/abseil-cpp-20211102.0/libabsl_debugging.a subprojects/abseil-cpp-20211102.0/libabsl_strings.a subprojects/abseil-cpp-20211102.0/libabsl_numeric.a subprojects/abseil-cpp-20211102.0/libabsl_profiling.a subprojects/abseil-cpp-20211102.0/libabsl_hash.a subprojects/abseil-cpp-20211102.0/libabsl_synchronization.a subprojects/abseil-cpp-20211102.0/libabsl_time.a subprojects/openssl-3.0.7/libcrypto.a subprojects/openssl-3.0.7/libssl.a subprojects/libuv-v1.44.2/libuv.a subprojects/libsrtp-2.4.2/libsrtp2.a subprojects/usrsctp-4e06feb01cadcd127d119486b98a4bd3d64aa1e7/libusrsctp.a deps/libwebrtc/liblibwebrtc.a subprojects/abseil-cpp-20211102.0/libabsl_types.a -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks -framework CoreFoundation
duplicate symbol ‘BaseEvent::getNextType()’ in:
deps/libwebrtc/liblibwebrtc.a(libwebrtc_call_rtp_transport_controller_send.cc.o)
deps/libwebrtc/liblibwebrtc.a(libwebrtc_api_transport_goog_cc_factory.cc.o)
duplicate symbol ‘BaseEvent::getNextType()’ in:
deps/libwebrtc/liblibwebrtc.a(libwebrtc_call_rtp_transport_controller_send.cc.o)
deps/libwebrtc/liblibwebrtc.a(libwebrtc_modules_bitrate_controller_send_side_bandwidth_estimation.cc.o)
duplicate symbol ‘BaseEvent::getNextType()’ in:
deps/libwebrtc/liblibwebrtc.a(libwebrtc_call_rtp_transport_controller_send.cc.o)
deps/libwebrtc/liblibwebrtc.a(libwebrtc_modules_bitrate_controller_loss_based_bwe_v2.cc.o)
duplicate symbol ‘BaseEvent::getNextType()’ in:
deps/libwebrtc/liblibwebrtc.a(libwebrtc_call_rtp_transport_controller_send.cc.o)
deps/libwebrtc/liblibwebrtc.a(libwebrtc_modules_congestion_controller_goog_cc_goog_cc_network_control.cc.o)
ld: 4 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [mediasoup-worker] Error 1

Google advice me this: objective c - What is GCC_NO_COMMON_BLOCKS used for? - Stack Overflow

But I have no clue how to apply this in meson.

I have created this branch GitHub - sarumjanuch/mediasoup at c++14_EventEmitter, where it is very easy to reproduce. Just try to compile the worker. Thank you very much for your attention and time!

There are already several defines in the meson file you can use an example: mediasoup/meson.build at 73fc28a5bccd730e66af92b7c801d74260499785 · versatica/mediasoup · GitHub

Compiler requirement change though is not necessarily straightforward. I’d love to move straight into C++17, it has even more nice features to enjoy and is already 5+ years old, so should not be a big concern. However, there might be people running mediasoup today on platforms where default compiler is not capable of C++14 or C++17, so this will be a breaking change for them.

@ibc @jmillan do you have a strong opinion on bumping compiler requirements?

If mediasoup with C++14 passes all CI tasks in GH I’m perfectly fine.

Seems like I dealt with the issue that I had, but i Still don’t like se shape of EventEmitter((( but it is the best I can create with my C++ knowledge(((

What about C++17?

I only for it Backport changes to congestion control from libwebrtc by sarumjanuch · Pull Request #922 · versatica/mediasoup · GitHub made a commit to test with c++17 c++14 is like centos 5, not even talking about c++11…

Hello @nazar-pc Seems like it is working fine with c++ 17 in most cases but in some it is not, can you take a look? Format · sarumjanuch/mediasoup@f59e74c · GitHub because for me it is dark wood( I spent weekend to make my Event Emitter work…

Seems like it is only Windows left… Just testing .emplace for clang · sarumjanuch/mediasoup@f2a0648 · GitHub

Ok, now I also fixed Windows. Try to fix it also for windows. Emplace is not required in c++17. · sarumjanuch/mediasoup@04af210 · GitHub

Feel free to send a PR

@ibc @jmillan do you have a strong opinion on bumping compiler requirements?

I’m Ok with it although we don’t know how many users would get stuck into current v3 due to this change. We don’t have this info.

At least gcc and clang versions that we are testing in CI do support C++17. Hence I would say we can migrate since those are the minimum compiler versions we are officially supporting.