rerun icon indicating copy to clipboard operation
rerun copied to clipboard

Rerun C++ SDK: undefined symbols (arch mismatch) when cross-compiling for macOS x64

Open rafaelspring opened this issue 1 year ago • 2 comments

Describe the bug Using the rerun C++ SDK. My machine is a MacBook Air M1 (arm64). I am including rerun in an app that (for various reasons) I need to compile to x64 architecture (using CMAKE_OSX_ARCHITECTURES = x86_64).

I'm getting tons of arch mismatch messages from the linker of this kind:

ld: warning: ignoring file '../arrow/lib/libarrow_bundled_dependencies.a[15](init.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '../arrow/lib/libarrow_bundled_dependencies.a[14](options.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '../arrow/lib/libarrow_bundled_dependencies.a[13](heap.c.o)': found architecture 'arm64', required architecture 'x86_64'
...

then further down many undefined symbols

Undefined symbols for architecture x86_64:
  "arrow::ExportType(arrow::DataType const&, ArrowSchema*)", referenced from:
      rerun::ComponentType::register_component() const in librerun_sdk.a[78](component_type.cpp.o)
  "arrow::ExportArray(arrow::Array const&, ArrowArray*, ArrowSchema*)", referenced from:
      rerun::ComponentBatch::to_c_ffi_struct(rr_component_batch&) const in librerun_sdk.a[76](component_batch.cpp.o)
      rerun::ComponentColumn::to_c_ffi_struct(rr_component_column&) const in librerun_sdk.a[77](component_column.cpp.o)
      rerun::TimeColumn::to_c_ffi_struct(rr_time_column&) const in librerun_sdk.a[188](time_column.cpp.o)
...

To Reproduce Steps to reproduce the behavior:

  • Use a Mac with arm CPU.
  • Create a CMake-based project (app or shared lib) that uses the rerun C++ SDK.
  • Set CMAKE_OSX_ARCHITECTURES to x86_64
  • Use SDK in code.
  • Build.

Expected behavior Code building without errors.

Desktop (please complete the following information): OS: macOS Sonoma 14.6.1

Rerun version Whatever is here: https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip

rafaelspring avatar Aug 20 '24 21:08 rafaelspring

Our CMake file is generally not set up for cross compilation and it's not something we test on CI either. Contributions very much welcome!

Wumpf avatar Sep 09 '24 09:09 Wumpf

I'm running the build with -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" from an intel mac, the static library generated is just x86_64 $ lipo -info libarrow_bundled_dependencies.a Non-fat file: libarrow_bundled_dependencies.a is architecture: x86_64

cedricnew92 avatar Sep 19 '24 01:09 cedricnew92

Related to:

  • https://github.com/rerun-io/rerun/issues/7445

Wumpf avatar Oct 22 '24 10:10 Wumpf