facebook / folly

An open-source C++ library developed and used at Facebook.
https://groups.google.com/forum/?fromgroups#!forum/facebook-folly
Apache License 2.0
28.29k stars 5.55k forks source link

bootstrap-osx-homebrew.sh - jemalloc undefined symbols on Mac OS 10.15.7 #1477

Open erlong16 opened 4 years ago

erlong16 commented 4 years ago

I'm trying to build follow the README.md instructions to build under OS X (Homebrew). The build fails with undefined symbol errors when linking logging_example:

[100%] Linking CXX executable logging_example
Undefined symbols for architecture x86_64:
  "_MallocExtension_Internal_GetNumericProperty", referenced from:
      folly::usingTCMalloc()::'lambda'()::operator()() const in libfolly.a(ExceptionString.cpp.o)
      folly::getTCMallocNumericProperty(char const*, unsigned long*) in libfolly.a(ExceptionString.cpp.o)
      folly::usingTCMalloc()::'lambda'()::operator()() const in libfolly.a(Singleton.cpp.o)
      folly::getTCMallocNumericProperty(char const*, unsigned long*) in libfolly.a(Singleton.cpp.o)
      folly::usingTCMalloc()::'lambda'()::operator()() const in libfolly.a(Demangle.cpp.o)
      folly::getTCMallocNumericProperty(char const*, unsigned long*) in libfolly.a(Demangle.cpp.o)
      folly::usingTCMalloc()::'lambda'()::operator()() const in libfolly.a(SymbolizePrinter.cpp.o)
      ...
  "folly::make_queue_observer_factory(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long)", referenced from:
      folly::QueueObserverFactory::make(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long) in libfolly.a(QueueObserver.cpp.o)
  "_dallocx", referenced from:
      folly::usingJEMalloc()::'lambda'()::operator()() const in libfolly.a(ExceptionString.cpp.o)
...

The script initially failed because it could not link against OpenSSL in the system. I was able to get around that issue by adding symlinks:

 _ change the version number as is in your system. _
sudo ln -s /usr/local/Cellar/openssl@1.1/1.1.1h/lib/libssl.1.1.dylib /usr/local/lib/libssl.dylib
sudo ln -s /usr/local/Cellar/openssl@1.1/1.1.1h/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.dylib

Looking at the installed jemalloc:

lipo -info /usr/local/Cellar/jemalloc/5.2.1_1/lib/libjemalloc.2.dylib Non-fat file: /usr/local/Cellar/jemalloc/5.2.1_1/lib/libjemalloc.2.dylib is architecture: x86_64

nm -gU /usr/local/Cellar/jemalloc/5.2.1_1/lib/libjemalloc.2.dylib

Shows the symbols are present in the lib.

What has to be done to get this to build successfully on Catalina?

LIZHICHAOUNICORN commented 1 year ago

@erlong16 did you figure out this problem ?