open64-compiler / open64

open64 compiler
78 stars 29 forks source link

'stddef.h' file not found when run openCC #16

Closed zqb-all closed 1 year ago

zqb-all commented 1 year ago
# cat /toolchain/helloworld/hello.c
#include <stdio.h>

int main()
{
        printf("hello\n");
}

# bin/openCC -clang -emit-llvm -fno-exceptions -O3 -OPT:malloc_alg=off -PHASE:c=off -c -sw -kp /toolchain/helloworld/hello.c
openCC WARNING: unknown flag: -sw
openCC WARNING: unknown flag: -kp
openCC WARNING: unsupported vendor_id in /proc/cpuinfo, defaulting to basic 64-bit x86.
In file included from /toolchain/helloworld/hello.c:1:
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
          ^~~~~~~~~~
1 error generated.
shinmingliu commented 1 year ago

The cause of such issue is the stdio.h in your OS environment does not have stddef.h in the same directory. Follow the following steps to resolve your issue:

  1. cd /usr/include
  2. find . -name stddef.h
  3. add "-I/usr/include/DIRECTORY" in your command line.
zqb-all commented 1 year ago

After add dir for stddef.h, stdarg.h, tr1/cstdio, error is error: use of undeclared identifier 'printf'

[root@10bd68b2e728 open64_20230606]# cat /toolchain/helloworld/hello.c
#include <stdio.h>

int main()
{
        printf("hello\n");
}
[root@10bd68b2e728 open64_20230606]# bin/openCC -clang -emit-llvm -fno-exceptions -O3 -OPT:malloc_alg=off -PHASE:c=off -c -sw -kp -I/usr/include -I/usr/include/linux -I/usr/include/c++/4.8.2/tr1 -I/usr/include/c++/4.8.2/ /toolchain/helloworld/hello.c
openCC WARNING: unknown flag: -sw
openCC WARNING: unknown flag: -kp
openCC WARNING: unsupported vendor_id in /proc/cpuinfo, defaulting to basic 64-bit x86.
/toolchain/helloworld/hello.c:5:2: error: use of undeclared identifier 'printf'
        printf("hello\n");
        ^
1 error generated.
Yvan-xy commented 1 year ago

check this solution https://github.com/open64-compiler/open64/issues/22#issuecomment-1660727799