If I want to compile the source code for a command (say cp.c) do I have to copy all the included files in the same directory of the source code? It would be a problem because the source code contains too many #include-s!!
But there are lots of options that you may want to use, like -Wall.
The headers should be in the development library directories, or local to the executable. For instance stdio.h is a standard I/O library header that should already be in a development library on your system. The -Wall switch will display warnings and errors to the console while it attempts to compile the binary.
> do I have to copy all the included files in the same directory of the source code?
That depends on what the include files are.
If it's things like
[tt]#include <stdio.h>[/tt]
then you don't have to do anything special. You can see all the standard include files in the /usr/include directory.
If it's things like
[tt]#include "cp.h"[/tt]
then that usually means it's a file local to the module being compiled. Typically, these are in either the same directory or a relative directory close by (say [tt]../inc/cp.h[/tt] )
If you have a lot of files close by, then you can do this on the command line
[tt]gcc -I../inc cp.c[/tt]
The -I option tells the compiler where else to find include files.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.