Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: macos build error : 'cstdint' file not found #761

Closed
lorentzenchr opened this issue Oct 12, 2024 · 2 comments
Closed

[BUG]: macos build error : 'cstdint' file not found #761

lorentzenchr opened this issue Oct 12, 2024 · 2 comments

Comments

@lorentzenchr
Copy link

lorentzenchr commented Oct 12, 2024

Problem description

I tried to create my first extension. My setup is:

  • OS: macos 15.0.1 (sequoia)
  • CPU: Intel i7-8559U
  • cmake version 3.30.0
  • virtual environment with pip install nanobind

Reproducible example code

Files

CMakeList.txt

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

  1. 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
    
  1. 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
    
@wojdyr
Copy link
Contributor

wojdyr commented Oct 12, 2024

<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?

@lorentzenchr
Copy link
Author

I removed and reinstalled Xcode. Now it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants