folly
folly copied to clipboard
[Mac M1] Failed to use Folly on Mac M1
I use "CMake" to build my project, but I encounter numerous errors when linking with Folly, like:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/cstddef:50:9: error: no member named 'nullptr_t' in the global namespace
My CMakeLists is
cmake_minimum_required(VERSION 3.0)
project(untitled3)
set(CMAKE_CXX_STANDARD 14)
add_executable(untitled3 main.cpp)
find_package(Folly REQUIRED)
target_include_directories(untitled3 PRIVATE ${FOLLY_INCLUDE_DIR})
message(${FOLLY_LIBRARIES})
target_link_libraries(untitled3 PRIVATE Folly::folly)
I want to know how I can resolve these challenging issues.
I had the same problem.
Reproduced this issue on my M1 Mac as well.
I used the following workarounds.
1: Use mac ports instead of brew I experienced the conflict between headers in brew and CLT before: stackoverflow link . Using mac ports to install folly seems to help me temporarily fix this problem.
sudo port install folly
brew uninstall folly
Sample CMakeLists.txt as below:
cmake_minimum_required(VERSION 3.0)
project(untitled3)
set(CMAKE_CXX_STANDARD 14)
add_executable(untitled3 main.cpp)
find_package(Folly REQUIRED)
find_package(gflags REQUIRED)
target_include_directories(untitled3 PRIVATE ${FOLLY_INCLUDE_DIR})
message(${FOLLY_LIBRARIES})
target_link_libraries(untitled3 Folly::folly)
2: Build from the source code Use git submodule add https://github.com/facebook/folly.git to add folly into your project and install necessary dependencies.
cmake_minimum_required(VERSION 3.10)
project(MyFollyProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(folly)
add_executable(main main.cpp)
target_link_libraries(main folly)