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

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

Open
brianabdl opened this issue Nov 22, 2023 · 6 comments
Open

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

brianabdl opened this issue Nov 22, 2023 · 6 comments

Comments

@brianabdl
Copy link

brianabdl commented Nov 22, 2023

OS: Ubuntu 20.04 LTS
Zig Version: 0.11.0
Ndk Version: 26.1.10909125

# ./zig-ndk setup ~/android-ndk-r26b           
zig_resource_dir=/snap/zig/lib/clang/16
ndk_resource_dir=/root/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17
ndk_sysroot=/root/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/sysroot

Copying ndk_resource_dir to zig_resource_dir ...
Copying ndk_sysroot to zig_resource_dir ...
Create wrapper ld.lld
Create wrapper ld
Create wrapper clang
Create wrapper clang++
Create wrapper ar

Test compiling C hello world progarm ...
In file included from <stdin>:1: 
In file included from /snap/zig/lib/clang/16/sysroot/usr/include/stdio.h:42:
/snap/zig/lib/clang/16/sysroot/usr/include/sys/types.h:32:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.
@zongou
Copy link
Owner

zongou commented Nov 22, 2023

I think i have found the cause, because ndk clang version and zig clang version are different, the resource is placed in wrong place, i will fix this soon

@zongou
Copy link
Owner

zongou commented Nov 22, 2023

This commit b41eaeb should fix this.

@brianabdl
Copy link
Author

Got another error saying unable to find library -lgcc
Here's the full log:

./zig-ndk setup android-ndk-r26b
zig_resource_dir=/usr/local/bin/lib/clang/11.0.1
ndk_resource_dir=android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17
ndk_sysroot=android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/sysroot

Copying ndk_resource_dir to zig_resource_dir ...
Copying ndk_sysroot to zig_resource_dir ...
Create wrapper ld.lld
Create wrapper ld
Create wrapper clang
Create wrapper clang++
Create wrapper ar

Test compiling C hello world progarm ...
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
zig: error: linker command failed with exit code 1 (use -v to see invocation)

@zongou
Copy link
Owner

zongou commented Nov 27, 2023 via email

@zongou
Copy link
Owner

zongou commented Nov 27, 2023 via email

@brianabdl
Copy link
Author

Oh yeah, my bad, I set it up in the wrong environment.
After I changed my environment, the build seems to produce the same error

root@22:~/mini-ndk# ./zig-ndk setup ~/android-ndk-r26b
zig_resource_dir=/snap/zig/lib/clang/16
ndk_resource_dir=/root/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17
ndk_sysroot=/root/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/sysroot

Copying ndk_resource_dir to zig_resource_dir ...
Copying ndk_sysroot to zig_resource_dir ...
Create wrapper ld.lld
Create wrapper ld
Create wrapper clang
Create wrapper clang++
Create wrapper ar

Test compiling C hello world progarm ...
In file included from <stdin>:1:
In file included from /snap/zig/lib/clang/16/sysroot/usr/include/stdio.h:42:
/snap/zig/lib/clang/16/sysroot/usr/include/sys/types.h:32:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.

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