facebook / folly

An open-source C++ library developed and used at Facebook.

Home Page:https://groups.google.com/forum/?fromgroups#!forum/facebook-folly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linker error trying to build on XCode M1 Mac Using Conda or Macports

battaglia01 opened this issue · comments

I'm not quite sure where things are going wrong, but after installing folly, and building a basic Hello World app using folly on M1 Max, I get this huge linker error. It looks like all of the missing symbols are from tcmalloc, such as "_MallocExtension_Internal_GetNumericProperty".

The header and library search paths are set up correctly. Instead, those symbols don't seem to be in libtcmalloc.dylib, although similarly-named ones are (like _MallocExtension_GetNumericProperty instead of _MallocExtension_Internal_GetNumericProperty).

I've tried installing this two ways and gotten the same error: first from conda-forge, and second from macports. I also tried the jemalloc version from conda-forge. Same result.

Here's the output:

Ld /Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug/folly-test normal (in target 'folly-test' from project 'folly-test')
    cd /Users/mike/Projects/C++/XCode/folly-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-macos12.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -L/Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug -L/Users/mike/Library/miniconda3/envs/folly_env/lib -F/Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug -filelist /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -v -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test_dependency_info.dat -o /Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug/folly-test

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-macos12.7
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 12.7.0 13.1 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -o /Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug/folly-test -L/Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug -L/Users/mike/Library/miniconda3/envs/folly_env/lib -filelist /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test.LinkFileList -object_path_lto /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test_lto.o -export_dynamic -no_deduplicate -no_adhoc_codesign -dependency_info /Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/folly-test.build/Debug/folly-test.build/Objects-normal/arm64/folly-test_dependency_info.dat -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a -F/Users/mike/Projects/C++/XCode/folly-test/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/mike/Projects/C++/XCode/folly-test/Build/Products/Debug
Undefined symbols for architecture arm64:
  "_MallocExtension_Internal_GetNumericProperty", referenced from:
      folly::usingTCMalloc()::'lambda'()::operator()() const in main.o
      folly::getTCMallocNumericProperty(char const*, unsigned long*) in main.o
  "folly::detail::formatOctal", referenced from:
      unsigned long folly::detail::uintToOctal<unsigned int>(char*, unsigned long, unsigned int) in main.o
  "folly::detail::formatBinary", referenced from:
      unsigned long folly::detail::uintToBinary<unsigned int>(char*, unsigned long, unsigned int) in main.o
  "folly::detail::formatHexLower", referenced from:
      unsigned long folly::detail::uintToHexLower<unsigned int>(char*, unsigned long, unsigned int) in main.o
  "folly::detail::formatHexUpper", referenced from:
      unsigned long folly::detail::uintToHexUpper<unsigned int>(char*, unsigned long, unsigned int) in main.o
  "folly::detail::to_ascii_table<10ull, folly::to_ascii_alphabet<false> >::data", referenced from:
      unsigned long folly::to_ascii_with<10ull, folly::to_ascii_alphabet<false>, 20ul>(char (&) [20ul], unsigned long long) in main.o
      unsigned long folly::to_ascii_with<10ull, folly::to_ascii_alphabet<false> >(char*, char const*, unsigned long long) in main.o
  "folly::Expected<int, folly::ConversionCode> folly::detail::str_to_integral<int>(folly::Range<char const*>*)", referenced from:
      std::__1::enable_if<(is_integral_v<int>) && (!(std::is_same<int, bool>::value)), folly::Expected<int, folly::ConversionCode> >::type folly::detail::convertTo<int>(folly::Range<char const*>*) in main.o
  "folly::detail::to_ascii_powers<10ull, unsigned long long>::data", referenced from:
      unsigned long folly::to_ascii_size<10ull>(unsigned long long) in main.o
      unsigned long folly::to_ascii_with<10ull, folly::to_ascii_alphabet<false>, 20ul>(char (&) [20ul], unsigned long long) in main.o
      unsigned long folly::to_ascii_with<10ull, folly::to_ascii_alphabet<false> >(char*, char const*, unsigned long long) in main.o
  "folly::detail::ScopeGuardImplBase::terminate()", referenced from:
      folly::detail::ScopeGuardImpl<void folly::fbvector<int, std::__1::allocator<int> >::emplace_back_aux<int>(int&&)::'lambda'(), true>::execute() in main.o
  "folly::detail::insertThousandsGroupingUnsafe(char*, char**)", referenced from:
      void folly::FormatValue<int, void>::doFormat<std::__1::enable_if<IsSomeString<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value, void>::type folly::BaseFormatter<folly::Formatter<false, int&>, false, int&>::appendTo<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const::'lambda'(folly::Range<char const*>)>(folly::FormatArg&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const in main.o
  "folly::FormatArg::initSlow()", referenced from:
      folly::FormatArg::FormatArg(folly::Range<char const*>) in main.o
  "folly::FormatArg::validate(folly::FormatArg::Type) const", referenced from:
      void folly::FormatValue<int, void>::format<std::__1::enable_if<IsSomeString<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value, void>::type folly::BaseFormatter<folly::Formatter<false, int&>, false, int&>::appendTo<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const::'lambda'(folly::Range<char const*>)>(folly::FormatArg&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const in main.o
  "_dallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_mallctl", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_mallctlbymib", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_mallctlnametomib", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_mallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_nallocx", referenced from:
      folly::goodMallocSize(unsigned long) in main.o
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
      folly::usingTCMalloc()::'lambda'()::operator()() const in main.o
  "_rallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_sallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
  "_sdallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
      folly::usingTCMalloc()::'lambda'()::operator()() const in main.o
  "_xallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in main.o
      void folly::fbvector<int, std::__1::allocator<int> >::emplace_back_aux<int>(int&&) in main.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Just tired it on macports with the same result, so it isn't just a problem with the conda package. I've edited the title.

Same issue if I run cmake/make manually. I totally deactivated conda and followed these instructions from the README:

First, I use port to get prereqs. There's also a folly port but I didn't install that.

  sudo port install \
    boost \
    cmake \
    gflags \
    git \
    google-glog \
    libevent \
    libtool \
    lz4 \
    lzma \
    openssl \
    snappy \
    xz \
    zlib

Then I get double-conversion:

  git clone https://github.com/google/double-conversion.git
  cd double-conversion
  cmake -DBUILD_SHARED_LIBS=ON .
  make
  sudo make install

Lastly, I run this:

  git clone https://github.com/facebook/folly.git
  cd folly
  mkdir _build
  cd _build
  cmake ..
  make
  sudo make install

I actually was getting some weirdness with fmt not being installed, so I installed libfmt10 and had to add to the include paths. Then, after all that, when going back to XCode, same thing: missing symbols (and they seem the same as they ones above).

So following the directions to the letter gives us that, and this linker error.

Ugh, never mind. Silly. Had multiple package directories conflicting and forgot to link with -lfolly on top of it.