mesonbuild/abseil-cpp

fails to build on macOS

benmkw opened this issue · 5 comments

Undefined symbols for architecture x86_64:
  "_CFRelease", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
  "_CFStringGetCString", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
  "_CFStringGetLength", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
  "_CFStringGetMaximumSizeForEncoding", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
  "_CFTimeZoneCopyDefault", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
  "_CFTimeZoneGetName", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in absl_time_internal_cctz_src_time_zone_lookup.cc.o
ld: symbol(s) not found for architecture x86_64

this should be related to abseil/abseil-cpp#283 but I've not figured out how to fix it yet, something about CoreFoundation was said elsewhere.

Looks like some dependency is missing? I think it should be fixed in the upstream.

ok so I just tried again and if I patch meson.build to have dependencies : [dependency('CoreFoundation')], like so:

absl_time_lib = library(
  'absl_time_lib',
  absl_time_sources,
  include_directories: absl_include_dir,
  link_with: [
    absl_base_lib,
    absl_numeric_lib,
    absl_strings_lib,
  ],
  dependencies : [dependency('CoreFoundation')],
)

it works, so I'm not sure whats the idioimatic way to only do this on macOS is, but then I could PR that

(thats the upstream fix in cmake https://github.com/chiumichael/abseil-cpp/blob/3bd3028e862e574d07a414de6e99273c1868cd3e/absl/time/CMakeLists.txt#L86)

If my understanding is correct that CoreFoundation is always installed on MacOS then I believe an idiomatic way would be to use dependency('CoreFoundation', required : false) similar to how -lm is handled: https://mesonbuild.com/howtox.html#add-math-library-lm-portably. I doubt other platforms will accidentally have CoreFoundation library available. Just please make sure to add a comment explaining that this is a MacOS-only required library.

Ok thanks! Created #5

thanks, works! 👍