Reputation: 5128
I've got a project that uses boost library compiled and installed on my macOS build machine using conan2 under CMake.
I've managed to reproduce the problem using the following minimal code. my project is built out of the following files (residing in the same folder) :
main.cpp:
#include <boost/algorithm/string.hpp>
int main() {
return 0;
}
conanfile.py (build+install the boost library):
from conan2 import ConanFile
class BoostExampleConan(ConanFile):
name = "BoostExample"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
requires = "boost/1.83.0" # Specify the Boost version you want
generators = "CMakeDeps", "CMakeToolchain"
default_options = {
"boost/*:header_only": False
"boost/*:with_stacktrace_backtrace"=False
"boost/*:without_locale"=True
}
def layout(self):
self.folders.source = "."
self.folders.build = "build"
default profile settings (under /Users/user/.conan2/profiles/default)
[settings]
os=Macos
arch=armv8
compiler=apple-clang
compiler.version=16
compiler.cppstd=gnu17
compiler.libcxx=libc++
build_type=Release
compiler.cppstd=17
os=Macos
[buildenv]
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CXXFLAGS=-stdlib=libc++
CFLAGS=-stdlib=libc++
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(SingleCppBoostExample)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(${CMAKE_SOURCE_DIR}/conan.cmake)
conan_cmake_configure(
REQUIRES boost/1.83.0
GENERATORS CMakeDeps CMakeToolchain
)
conan_cmake_autodetect(settings)
set(CONAN_INSTALL_ARGS "--build=missing")
conan_cmake_install(
PATH_OR_REFERENCE .
SETTINGS ${settings}
PROFILE default
BUILD missing
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
add_executable(my_boost_program main.cpp)
find_package(Boost REQUIRED)
target_link_libraries(my_boost_program Boost::system Boost::filesystem)
When running cmake --build .
I get the following error :
In file included from /Users/user/Developer/BoostExampleConan/main.cpp:1:
In file included from /Users/user/.conan2/p/b/boost694222cbc5cd8/p/include/boost/algorithm/string.hpp:18:
In file included from /Users/user/.conan2/p/b/boost694222cbc5cd8/p/include/boost/algorithm/string/std_containers_traits.hpp:18:
In file included from /Users/user/.conan2/p/b/boost694222cbc5cd8/p/include/boost/config.hpp:44:
/Users/user/.conan2/p/b/boost694222cbc5cd8/p/include/boost/config/detail/select_stdlib_config.hpp:26:14: fatal error: 'cstddef' file not found
26 | # include <cstddef>
Any ideas how to resolve it? do I need to set different compiler ?
Thanks
Upvotes: 1
Views: 79