Homebrew libraries & CMake on MacOS Sonoma: ld does not find symbols despite correct specified architecture

Problem

I am trying to port a C++ project from Linux to MacOs sonoma with the arm64 architecture.
Configuring is done via CMAKE and the following toolchain

  • GCC 14 from Homebrew
  • HDF5 (installed via Homebrew)
  • Boost program options (installed via Homebrew)

The configuration and compilation step is finished correctly. However, when the project is supposed to be linked together several symbols cannot be resolved by ld and the following error occurs:

ld: symbol(s) not found for architecture arm64

However, when I checked the .dylib files of the homebrew formulae I get the correct architecture:

➜  ~ file /opt/homebrew/lib/libhdf5.dylib 
/opt/homebrew/lib/libhdf5.dylib: Mach-O 64-bit dynamically linked shared library arm64
➜  ~ file /opt/homebrew/lib/libboost_program_options.dylib 
/opt/homebrew/lib/libboost_program_options.dylib: Mach-O 64-bit dynamically linked shared library arm64

The CMake project compiles without any errors but it seems that the libraries are not visible to the linker.
Do I have to add something to CMake configuration for this?

Full linker error output

/opt/homebrew/bin/g++-14 -std=c++17 -Wpedantic -Wall -Wextra -g  -g -DNUM_OUT -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/ISHTAR.dir/main.cpp.o -o ISHTAR  -Wl,-rpath,/opt/homebrew/lib  /opt/homebrew/Cellar/gsl/2.8/lib/libgsl.dylib  /opt/homebrew/Cellar/gsl/2.8/lib/libgslcblas.dylib  /opt/homebrew/lib/libboost_program_options-mt.dylib  /opt/homebrew/lib/libhdf5_cpp.310.0.3.dylib  /opt/homebrew/lib/libhdf5_hl_cpp.310.0.3.dylib  /opt/homebrew/lib/libhdf5_hl.310.0.3.dylib  /opt/homebrew/lib/libhdf5.310.3.0.dylib && :
Undefined symbols for architecture arm64:
  "H5::H5File::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, H5::FileAccPropList const&)", referenced from:
      test_hdf5_support() in main.cpp.o
  "H5::H5File::H5File(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, H5::FileCreatPropList const&, H5::FileAccPropList const&)", referenced from:
      init_HDF5_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>) in main.cpp.o
      test_hdf5_support() in main.cpp.o
  "boost::program_options::to_internal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)", referenced from:
      std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> boost::program_options::to_internal<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) in main.cpp.o
  "boost::program_options::validation_error::get_template[abi:cxx11](boost::program_options::validation_error::kind_t)", referenced from:
      boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int) in main.cpp.o
  "boost::program_options::basic_parsed_options<char> boost::program_options::parse_config_file<char>(std::basic_istream<char, std::char_traits<char>>&, boost::program_options::options_description const&, bool)", referenced from:
      read_config(int, char**) in main.cpp.o
  "boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int)", referenced from:
      read_config(int, char**) in main.cpp.o
      read_config(int, char**) in main.cpp.o
      read_config(int, char**) in main.cpp.o
  "boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)", referenced from:
      void boost::program_options::validate<double, char>(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, double*, long) in main.cpp.o
      void boost::program_options::validate<int, char>(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, int*, long) in main.cpp.o
  "boost::program_options::error_with_option_name::error_with_option_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)", referenced from:
      boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int) in main.cpp.o
  "boost::program_options::arg[abi:cxx11]", referenced from:
      boost::program_options::typed_value<bool, char>::name[abi:cxx11]() const in main.cpp.o
      boost::program_options::typed_value<double, char>::name[abi:cxx11]() const in main.cpp.o
      boost::program_options::typed_value<int, char>::name[abi:cxx11]() const in main.cpp.o
      boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char>::name() const in main.cpp.o
  "boost::program_options::detail::cmdline::cmdline(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)", referenced from:
      boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*) in main.cpp.o
  "boost::program_options::validate(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, int)", referenced from:
      boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char>::xparse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) const in main.cpp.o
  "boost::program_options::validate(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, bool*, int)", referenced from:
      boost::program_options::typed_value<bool, char>::xparse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) const in main.cpp.o
  "boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)", referenced from:
      read_config(int, char**) in main.cpp.o
  "H5::H5Location::createGroup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long) const", referenced from:
      add_group(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>) in main.cpp.o
  "H5::H5Location::openDataSet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, H5::DSetAccPropList const&) const", referenced from:
      extend_group_with_vector_int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<int, std::allocator<int>>) in main.cpp.o
      update_group_with_vector_double(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<double, std::allocator<double>>) in main.cpp.o
      extend_group_with_vector_double(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<double, std::allocator<double>>) in main.cpp.o
      read_vector_int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>) in main.cpp.o
      read_vector_double(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>) in main.cpp.o
      test_hdf5_support() in main.cpp.o
  "H5::H5Location::createDataSet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, H5::DataType const&, H5::DataSpace const&, H5::DSetCreatPropList const&, H5::DSetAccPropList const&, H5::LinkCreatPropList const&) const", referenced from:
      add_group_with_vector_double(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<double, std::allocator<double>>) in main.cpp.o
      add_group_with_vector_int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<int, std::allocator<int>>) in main.cpp.o
      test_hdf5_support() in main.cpp.o
  "boost::program_options::error_with_option_name::substitute_placeholders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const", referenced from:
      vtable for boost::program_options::invalid_option_value in main.cpp.o
      vtable for boost::program_options::validation_error in main.cpp.o
      vtable for boost::wrapexcept<boost::program_options::validation_error> in main.cpp.o
      vtable for boost::wrapexcept<boost::program_options::invalid_option_value> in main.cpp.o
  "boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, bool) const", referenced from:
      vtable for boost::program_options::typed_value<bool, char> in main.cpp.o
      vtable for boost::program_options::typed_value<double, char> in main.cpp.o
      vtable for boost::program_options::typed_value<int, char> in main.cpp.o
      vtable for boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char> in main.cpp.o
ld: symbol(s) not found for architecture arm64

It seems like the affected libraries are not installed under the correct architecture so I tried already to see if the installed libraries are installed within the correct architecture and resetting the CMake project.
However, all files were installed in the arm64 architecture.
The CMake file works correctly on Linux x86_64.

New contributor

MXI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật