homebrew-px4 icon indicating copy to clipboard operation
homebrew-px4 copied to clipboard

px4-dev fails to build on M1 (Rosetta) macOS: "Can't find boost headers" during [email protected] configure step

Open pawelpetruch opened this issue 2 months ago • 8 comments

Hi PX4 team

Following steps from: https://docs.px4.io/main/en/dev_setup/dev_env_mac

on M1 Pro, macOS Sequoia 15.6.1 (24G90) running under Rosetta (Intel/x86_64), brew install px4-dev consistently fails when building the [email protected] dependency. The error is that Boost headers cannot be found, even though [email protected] is installed in /usr/local/opt/[email protected].

System details:

macOS: Sequoia 15.6.1 (Intel via Rosetta on Apple Silicon)

Homebrew prefix (Intel): /usr/local

Boost: [email protected] installed at /usr/local/opt/[email protected]

Failure log (tail of 02.configure.log):

checking for boost/noncopyable.hpp... no
Can't find boost headers. Please check the location of the boost
distribution and rerun configure using the --with-boost=DIR option.

Expected: [email protected] should detect Boost headers located at: /usr/local/opt/[email protected]/include/boost/noncopyable.hpp

.zshrc content

# --- Architecture switchers ---
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"

# --- Auto-select Homebrew ---
if [[ "$(arch)" == "arm64" ]]; then
  # Native Apple Silicon brew
  export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
  export HOMEBREW_PREFIX="/opt/homebrew"
  alias brew="/opt/homebrew/bin/brew"
else
  # Rosetta / Intel brew
  export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
  export HOMEBREW_PREFIX="/usr/local"
  alias brew="/usr/local/bin/brew"
fi

pawelpetruch avatar Sep 23 '25 11:09 pawelpetruch

[email protected] with the following changes passed

class AsioAT1108 < Formula
  desc "Cross-platform C++ Library for asynchronous programming"
  homepage "https://think-async.com/Asio"
  url "https://downloads.sourceforge.net/project/asio/asio/1.10.8%20%28Stable%29/asio-1.10.8.tar.bz2"
  sha256 "26deedaebbed062141786db8cfce54e77f06588374d08cccf11c02de1da1ed49"
  license "BSL-1.0"
  head "https://github.com/chriskohlhoff/asio.git"
  keg_only :versioned_formula

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "pkg-config" => :build
  depends_on "[email protected]"

  def install
    ENV.cxx11

    boost = Formula["[email protected]"]

    # Discover the macOS SDK path (needed for standard C++ headers on modern macOS)
    sdk = Utils.popen_read("xcrun --sdk macosx --show-sdk-path").chomp
    libcxx = "#{sdk}/usr/include/c++/v1"

    # Regenerate the configure script
    system "autoconf"

    # Configure with explicit Boost prefix; pass flags *inline* so configure can't ignore them
    args = %W[
      --disable-dependency-tracking
      --disable-silent-rules
      --prefix=#{prefix}
      --with-boost=#{boost.opt_prefix}
    ]

    cppflags = "-I#{boost.opt_include} -I#{libcxx} -isysroot #{sdk}"
    cxxflags = "-std=c++11 -I#{boost.opt_include} -I#{libcxx} -isysroot #{sdk}"
    ldflags  = "-L#{boost.opt_lib} -isysroot #{sdk}"

    system "./configure",
          *args,
          "CPPFLAGS=#{cppflags}",
          "CXXFLAGS=#{cxxflags}",
          "LDFLAGS=#{ldflags}",
          # Preseed the old Autoconf header check we hit earlier:
          "ac_cv_header_boost_noncopyable_hpp=yes"

    system "make", "install"
    pkgshare.install "src/examples"
  end


  test do
    # Use the HTTP server example to verify functionality
    httpserver = pkgshare/"examples/cpp03/http/server/http_server"
    pid = fork do
      exec httpserver, "127.0.0.1", "8080", "."
    end
    sleep 1
    begin
      assert_match "404 Not Found", shell_output("curl -s http://127.0.0.1:8080")
    ensure
      Process.kill "TERM", pid
      Process.wait pid
    end
  end
end

pawelpetruch avatar Sep 23 '25 12:09 pawelpetruch

@pawelpetruch Thanks. We're aware that there are problems, which are supposed to be sorted out by https://github.com/PX4/PX4-Autopilot/pull/25204

I can't comment on this, but perhaps @mrpollo or @ryanjAA can.

hamishwillee avatar Sep 23 '25 22:09 hamishwillee

Can you run this without Rosetta? @pawelpetruch I'm on M3 Max and have no issues

mrpollo avatar Sep 24 '25 16:09 mrpollo

The issue arm side is not so much Arm (anymore). That’s largely been sorted but huge differences are present depending on os variant. I have this working on a few but I’m going to overhaul the install script and we need to lockdown gcc in lockstep with Ubuntu

For this specific issue above just create a virtual environment and install boost in there.

ryanjAA avatar Sep 24 '25 16:09 ryanjAA

I should note that using Rosetta or not changes where homebrew is installed. With Rosetta brew installs into usr/local and native it goes in opt/hombrew so you’re likely just not picking it up on path.

Put brew on PATH via

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"

But depends on if Rosetta or not. That’s native.

ryanjAA avatar Sep 24 '25 17:09 ryanjAA

Can you run this without Rosetta? @pawelpetruch I'm on M3 Max and have no issues

@mrpollo - tried without Rosetta, see logs below from: ...../Library/Logs/Homebrew/fastcdr/02.cmake.log

un Build Command(s): /opt/homebrew/opt/cmake/bin/cmake -E env VERBOSE=1 /opt/homebrew/Library/Homebrew/shims/mac/super/gmake -f Makefile
/opt/homebrew/opt/cmake/bin/cmake -S/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22 -B/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/homebrew/opt/cmake/bin/cmake -E cmake_progress_start /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/CMakeFiles /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build//CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make  -f src/cpp/CMakeFiles/fastcdr.dir/build.make src/cpp/CMakeFiles/fastcdr.dir/depend
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build && /opt/homebrew/opt/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22 /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp/CMakeFiles/fastcdr.dir/DependInfo.cmake "--color="
/Library/Developer/CommandLineTools/usr/bin/make  -f src/cpp/CMakeFiles/fastcdr.dir/build.make src/cpp/CMakeFiles/fastcdr.dir/build
[ 28%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/Cdr.cpp.o
[ 28%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/FastCdr.cpp.o
[ 57%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/FastBuffer.cpp.o
[ 71%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/exceptions/Exception.cpp.o
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/FastCdr.cpp.o -MF CMakeFiles/fastcdr.dir/FastCdr.cpp.o.d -o CMakeFiles/fastcdr.dir/FastCdr.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/FastCdr.cpp
[ 85%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/exceptions/BadParamException.cpp.o
[ 85%] Building CXX object src/cpp/CMakeFiles/fastcdr.dir/exceptions/NotEnoughMemoryException.cpp.o
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/FastBuffer.cpp.o -MF CMakeFiles/fastcdr.dir/FastBuffer.cpp.o.d -o CMakeFiles/fastcdr.dir/FastBuffer.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/FastBuffer.cpp
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/exceptions/BadParamException.cpp.o -MF CMakeFiles/fastcdr.dir/exceptions/BadParamException.cpp.o.d -o CMakeFiles/fastcdr.dir/exceptions/BadParamException.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/BadParamException.cpp
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/exceptions/NotEnoughMemoryException.cpp.o -MF CMakeFiles/fastcdr.dir/exceptions/NotEnoughMemoryException.cpp.o.d -o CMakeFiles/fastcdr.dir/exceptions/NotEnoughMemoryException.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/NotEnoughMemoryException.cpp
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/exceptions/Exception.cpp.o -MF CMakeFiles/fastcdr.dir/exceptions/Exception.cpp.o.d -o CMakeFiles/fastcdr.dir/exceptions/Exception.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/Exception.cpp
cd /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/src/cpp && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DFASTCDR_SOURCE -Dfastcdr_EXPORTS -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include -I/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/build/include -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -fPIC -std=c++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wold-style-cast -MD -MT src/cpp/CMakeFiles/fastcdr.dir/Cdr.cpp.o -MF CMakeFiles/fastcdr.dir/Cdr.cpp.o.d -o CMakeFiles/fastcdr.dir/Cdr.cpp.o -c /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/Cdr.cpp
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/Exception.cpp:In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/BadParamException.cpp:15:
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/exceptions/BadParamException.h:18In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/exceptions/NotEnoughMemoryException.cpp:15:
:
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/exceptions/Exception.h:19:10: /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/exceptions/NotEnoughMemoryException.h:18:
/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/exceptions/Exception.h:19:10: fatal error: 15:
/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/exceptions/Exception.h:fatal error: 'string' file not found'string' file not found
   19 | #include <stri
   19 | #include <string>
      ng>|          ^~~~~~~~

      |          ^~~~~~~~
19:10: fatal error: 'string' file not found
   19 | #include <string>
      |          ^~~~~~~~
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/FastCdr.cpp:15:
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/FastCdr.h:19:
/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/FastBuffer.hIn file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/Cdr.cpp:15:
In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/Cdr.h:19:
/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/FastBuffer.h:20:10: fatal error: 'cstdio' file not found
:   20:10In file included from /private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/src/cpp/FastBuffer.cpp:: fatal error: 'cstdio' file not found
   20 | #i20 | #n15:
/private/tmp/fastcdr-20250925-91389-wf903a/Fast-CDR-1.0.22/include/fastcdr/FastBuffer.h:20:10: clufatal error: de i'cstdio' file not found
nc   20 | <cstdl#io>
      |          ^~~~~~~~ude 
<inccstdio>lu

pawelpetruch avatar Sep 25 '25 19:09 pawelpetruch

Can you run this without Rosetta? @pawelpetruch I'm on M3 Max and have no issues

@mrpollo - tried without Rosetta, see logs below from: ...../Library/Logs/Homebrew/fastcdr/02.cmake.log

un Build Command(s): /opt/homebrew/opt/cmake/bin/cmake -E env VERBOSE=1 

That's not a PX4/Fast-CDR problem. Your toolchain can’t see libc++ (aka C++ library headers (e.g., , ) and they aren't found by the compiler).

Either your Command Line Tools SDK / header paths are broken or pointing to an incomplete SDK (more likely path).

If xcode-select points to CLT instead of the Xcode, or your SDKROOT/include env vars are set incorrectly, clang++ dies (uses an SDK missing usr/include/c++/v1).

  1. I'd clear any overrides (unset SDKROOT CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH)

  2. Check where the tools point & what SDK is used

xcode-select -p xcrun --sdk macosx --show-sdk-path echo | clang++ -xc++ - -v 2>&1 | sed -n '/#include <...> search starts here:/, /End of search list./p'

and basically if you don’t see a .../usr/include/c++/v1 path in the list, your headers aren’t being found.

Then either switch to full Xcode toolchain (has complete headers) or reinstall CLT

The real check is to make sure headers actually exist:

ls "$(xcrun --sdk macosx --show-sdk-path)/usr/include/c++/v1/string"

Then simply clean and rebuild

ryanjAA avatar Sep 25 '25 19:09 ryanjAA

Running:

sudo xcode-select -s /Applications/Xcode.ap
brew reinstall px4/px4/fastcdr --build-from-source -v

fixed the issue and I could run brew install px4-dev px4-sim just fine.

pawelpetruch avatar Oct 14 '25 16:10 pawelpetruch