Trying to compile a c file that has the header:
#include <sys/wait.h>
I'm using Cygwin to compile it and it keeps giving me this error whenever I type in gcc minishell.c -o minishell:
minishell.c:4:22: fatal error: sys/wait.h: No such file or directory compilation terminated.
Any clue what the heck is going on?
That's because compiler, in this case, does not know how to reach/find sys/wait.h file so that it can include this file in compilation process. To check which all places compiler will try to find the files, refer:
How to tell C++ library path in Cygwin and MinGW
Above post/link also tells about include paths.
Related
I receive the error in the title after running the code below.
#include<stdio.h>
int main()
{
printf("hello World!\n");
return 0;
}
ADDITIONAL INFO:
header stdio.h is included in usr/include directory.
gcc compiler.
using latest Ubuntu Operating System.
C program.
file name binaryWords.c
command line: "gcc binaryWords.c -o BinaryWords."
ERROR MESSAGE FULL:
In file included from /usr/local/include/stdio.h:11:0,
from binaryWords.c:1:
/usr/local/include/thread.h:11:10: fatal error: interrupt.h: No such file or directory
#include <interrupt.h>
^~~~~~~~~~~~~
compilation terminated.
How can I fix this error?
Why is interrupt.h needed?
In Ubuntu system there is directory usr/include and usr/local/include. I had a header stdio.h for a xinu embedded system which implemented a missing interrupt.h header located in usr/local/include, hence "interrupt.h" not found error. In usr/include is the standard C library with the standard stdio.h. Once I removed the headers in usr/local/include the simple helloWorld program compiled and I was able to run the program.
possible conclusion, GCC compiler searches in usr/local/include directory before searching in usr/include directory.
I am trying to compile the gjh solver - written in C - into an executable file in windows. It is available on netlib
I downloaded the c file and am using gcc compiler via WinGW on windows' command prompt. Trying to compile the gjh.c file directly gave me an error that says:
gjh.c:33:21: fatal error: getstub.h: No such file or directory
#include "getstub.h"
compilation terminated.
I assumed that compiling gjh.c requires the dependency getstub.h.
getstub.h is not the only dependency required, there are other dependencies, namely: arith.h, asl.h, funcadd.h, and stdio1.h. All of these files are available on the same link where I found getstub.h. However, arith.h0 and stdio1.h0 are available instead of arith.h and stdio1.h.
Are these files the same? I tried to rename the .h0 files to .h and tried to compile gjh.c, but I got this error:
collect2.exe: error: ld returned 1 exit status
Are the two files the same? If not, is there any way for me to compile the gjh solver successfully into an .exe?
If that's the only problem in compiling, try using the -I switch in gcc:
gcc -I/my/path/to/include/files -o gjh gjh.c
the -I switch hints to gcc where to find your #include files.
I am not sure about the stdio1.h. I think your approach to rename is OK but that reference to external functions such as Sprintf. You need to link with a library defining that. If you know where it comes from, use the -L and -l switch in gcc for that:
gcc -I/my/path/to/include/files -L/my/path/to/library -lnameoflibrary \
-o gjh gjh.c
I am trying to compile this with tcc
and I have these errors
Before the error it was "Cannot find pthread.h" and I copied
pthread,pthread_compat,pthread_signal,pthread_time,pthread_unistd header files from gcc include dir to tcc include dir ! ... and now I have the above errors.. I think is something with linking but I don't know exactly :/
Copying header files from the gcc include dir was neither required nor a good idea; better use tcc option: -Igcc-include-dir-path.
Anyway, now you will need to link your program to the pthread library in order complete build. Look in the gcc directory for a file named pthread.a or pthread.lib, there you have the gcc libraries directory. Then when you get this directory path, add the following options to the tcc command-line: -Lgcc-library-dir-path -pthread.
I installed libsrtp on my ubuntu machine according to the directives in read me, the tests worked fine, and the rptw utility included in libsrtp worked perfectly too. But when I tried to include srtp.h in my HelloWorld! program, it gives me an error that:
fatal error: srtp.h: No such file or directory
compilation terminated.
Concretely, my main file is this
#include "srtp.h"
int main()
{
return 0;
}
My libsrtp.a is present in /usr/local/lib/lib
I used this gcc statement from this blog:
gcc -static main.c -L/usr/local/lib/lib/ -llibsrtp -o main
I will be deeply grateful for any help.
You've found your libsrtp.a , but where is srtp.h ? You'll need to tell the compiler where to search for included files if it's not in a standard location with the -I flag.
Perhaps you need a -I/usr/local/include or -I/usr/local/include/srtp
Note also that -llibsrtp is likely wrong, you need to give the name without the lib prefix. So that makes it -lsrtp
I just started using llvm and trying to print basic commands of llvm, when i tried to execute
clang -cc1 ~/hello.c -ast-print
getting following error
fatal error: 'stdio.h' file not found
#include<stdio.h>
^
int main()
{
printf("hi\n");
return 0;
}
1 error generated.
so please help me out.
Thanks!
With -cc1 you invoke the frontend, not the gcc-compatible compiler driver. The latter knows how to find standard header includes, the former doesn't.
If you want to use -cc1 with files including from standard libraries, then either supply all relevant paths with -I, or just run it on preprocessed files.