You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmake_minimum_required(VERSION 3.15...3.27)
project(my_project) # Replace 'my_project' with the name of your project
if (CMAKE_VERSION VERSION_LESS 3.18)
set(DEV_MODULE Development)
else()
set(DEV_MODULE Development.Module)
endif()
find_package(Python 3.8 COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Detect the installed nanobind package and import it into CMake
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG REQUIRED)
nanobind_add_module(my_ext my_ext.cpp)
my_ext.cpp
#include <nanobind/nanobind.h>
int add(int a, int b) { return a + b; }
NB_MODULE(my_ext, m) {
m.def("add", &add);
}
Commands
cmake -S . -B build
-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: /Users/lorentzen/github/python3_general/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter Development.Module
-- Configuring done (1.6s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/lorentzen/github/test_nanobind/build
cmake --build build
[ 7%] Building CXX object CMakeFiles/nanobind-static.dir/Users/lorentzen/github/python3_general/lib/python3.12/site-packages/nanobind/src/nb_internals.cpp.o
In file included from /Users/lorentzen/github/python3_general/lib/python3.12/site-packages/nanobind/src/nb_internals.cpp:10:
/Users/lorentzen/github/python3_general/lib/python3.12/site-packages/nanobind/include/nanobind/nanobind.h:30:10: fatal error: 'cstdint' file not found
30 | #include <cstdint>
| ^~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/nanobind-static.dir/Users/lorentzen/github/python3_general/lib/python3.12/site-packages/nanobind/src/nb_internals.cpp.o] Error 1
make[1]: *** [CMakeFiles/nanobind-static.dir/all] Error 2
make: *** [all] Error 2
The text was updated successfully, but these errors were encountered:
<cstdint> is a header from the C++ standard library. It seems that your compiler is not setup correctly.
Can it compile any C++ code that uses the standard library?
Problem description
I tried to create my first extension. My setup is:
pip install nanobind
Reproducible example code
Files
CMakeList.txt
my_ext.cpp
Commands
cmake -S . -B build
cmake --build build
The text was updated successfully, but these errors were encountered: