ClangSharp icon indicating copy to clipboard operation
ClangSharp copied to clipboard

Fatal error: 'stddef.h' file not found.

Open Ordsall opened this issue 4 years ago • 2 comments

Trying to use ClangSharpPInvokeGenerator @GenerateClang.rsp to generate sources using Ubuntu 20.04 x64 and libClangSharp.so libclang.so libLLVM.so from NuGet packages for Ubuntu 20.04, I get next errors: Diagnostics for 'src/include/api/idetector.hpp': /../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/cxxabi_init_exception.h:38:10: fatal error: 'stddef.h' file not found Skipping 'src/include/api/idetector.hpp' due to one or more errors listed above.

If I trying build libClangSharp.so myself, library building successfully. But, after using it, I get next errors: Error: System.InvalidCastException: Unable to cast object of type 'ClangSharp.Decl' to type 'ClangSharp.TranslationUnitDecl'

Ordsall avatar Nov 20 '21 18:11 Ordsall

Trying to use ClangSharpPInvokeGenerator @GenerateClang.rsp to generate sources using Ubuntu 20.04 x64 and libClangSharp.so libclang.so libLLVM.so from NuGet packages for Ubuntu 20.04, I get next errors: Diagnostics for 'src/include/api/idetector.hpp': /../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/cxxabi_init_exception.h:38:10: fatal error: 'stddef.h' file not found Skipping 'src/include/api/idetector.hpp' due to one or more errors listed above.

This sounds like one of the standard include directories isn't being passed into Clang.

If I trying build libClangSharp.so myself, library building successfully. But, after using it, I get next errors: Error: System.InvalidCastException: Unable to cast object of type 'ClangSharp.Decl' to type 'ClangSharp.TranslationUnitDecl'

This sounds like a mismatch between the libClang version and the expected version in libClangSharp. Clang makes breaking ABI changes almost every release and so you must ensure they match up exactly.

tannergooding avatar Nov 21 '21 17:11 tannergooding

fatal error: 'stddef.h' file not found Skipping 'src/include/api/idetector.hpp' due to one or more errors listed above.

FYI for anyone who hits these kind of errors on macOS, quick fix for standard headers is:

  1. get SDK path
xcrun --show-sdk-path
  1. from output above, add -I <SDK path>/usr/include to the ClangSharpPInvokeGenerator invocation or response file.

(at least on macOS 10.14 / XCode 11)

ihnorton avatar Jan 20 '22 17:01 ihnorton