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

How to build Universal binaries on MacOS? #2922

Open
crazydef opened this issue Apr 10, 2024 · 0 comments
Open

How to build Universal binaries on MacOS? #2922

crazydef opened this issue Apr 10, 2024 · 0 comments
Labels
Type: Question Questions or things that require clarification

Comments

@crazydef
Copy link

Hi,

I've managed to get our MacOS Devops pipeline to build a simple version of srt using the instructions for building on MacOS:

./configure
make

Which seems to work fine. (Outside of me needing to go fishing for the libraries and headers needed for including in a build package.)

But this appears to only build for the architecture of the build machine in question. So I've been trying to build with CMake instead, but without much luck.

I took our Linux build pipeline as a starting point (we also build on Windows in the same way) and added the necessary CMake arguments to build universal binaries:
(New lines for clarity)

cmake -G "Xcode"
      -Wno-dev
      -D CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
      -D CMAKE_BUILD_TYPE=$(Configuration)
      -D USE_CXX_STD=20
      -D ENABLE_STATIC=Off
      -D ENABLE_APPS=Off
      -D ENABLE_ENCRYPTION=Off
      -D CMAKE_INSTALL_BINDIR=$(Build.ArtifactStagingDirectory)/bin
      -D CMAKE_INSTALL_INCLUDEDIR=$(Build.ArtifactStagingDirectory)/include
      -D CMAKE_INSTALL_LIBDIR=$(Build.ArtifactStagingDirectory)/lib
      -D INSTALL_SHARED_DIR=$(Build.ArtifactStagingDirectory)/bin
      -D CMAKE_DEBUG_POSTFIX=.macOS.Debug
      -D CMAKE_RELEASE_POSTFIX=.macOS.Release
xcodebuild -verbose -project SRT.xcodeproj -configuration $(Configuration) -parallelizeTargets

But I'm hitting some linker issues that I haven't been able to figure out:


ld: Undefined symbols:
  std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char>>::str() const, referenced from:
      srt::CUDTUnited::CONID(int) in api.o
      srt::sockaddr_any::str() const in api.o
      srt_logging::LogDispatcher::Proxy::~Proxy() in api.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [71]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [71]) in api.o
      srt::CRcvBuffer::strFullnessState(int, srt::sync::TimePoint<srt::sync::steady_clock> const&) const in buffer_rcv.o
      srt::FixedArray<srt::CRcvBuffer::Entry>::throw_invalid_index(int) const in buffer_rcv.o
      srt::CIPAddress::show(sockaddr const*) in common.o
      srt::CIPAddress::show(sockaddr const*) in common.o
      ...
  std::__1::locale::use_facet(std::__1::locale::id&) const, referenced from:
      srt_logging::LogDispatcher::Proxy::~Proxy() in api.o
      std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::__put_character_sequence[abi:v160006]<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*, unsigned long) in api.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [71]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [71]) in api.o
      srt::CUDT::tsbpd(void*) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [85]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [85]) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [72]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [72]) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [45]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [45]) in core.o
      ...
  std::__1::ios_base::getloc() const, referenced from:
      srt_logging::LogDispatcher::Proxy::~Proxy() in api.o
      std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::__put_character_sequence[abi:v160006]<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*, unsigned long) in api.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [71]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [71]) in api.o
      srt::CUDT::tsbpd(void*) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [85]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [85]) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [72]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [72]) in core.o
      void srt_logging::LogDispatcher::PrintLogLine<char const (&) [45]>(char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const (&) [45]) in core.o
      ...
  std::logic_error::logic_error(char const*), referenced from:
      std::length_error::length_error[abi:v160006](char const*) in api.o
      std::out_of_range::out_of_range[abi:v160006](char const*) in api.o

(etc etc... there's a few pages worth of these.)

Obviously all missing symbols are from the C++ standard library, but I haven't been able to figure out exactly what I'm missing.

So, I guess, my question is: What am I missing? :) Or is there a way to pass the necessary CMake command line arguments to configure?

@crazydef crazydef added the Type: Question Questions or things that require clarification label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Questions or things that require clarification
Projects
None yet
Development

No branches or pull requests

1 participant