Compiling C in Linux
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!!
|
No.
There are two ways to include #include files: Code:
#include <stdio.h> Before you go too far down the C path, you may want to check Amazon.com or your local bookseller for a good introductory text. |
It depends on how you've configured your system. If you've used a default configuration, the include search paths should be defined, and "standard" system include files should not need to be copied to your "work" directory. If you've used your own configuration, you're -- of course -- "on your own."
If you're new to Linux and/or compilation on Linux distributions, you should try one of the IDEs available with most distributions. Or designed for specific "desktop" environments (e.g., GNOME or KDE or ...). |
You may find this useful:
http://www.advancedlinuxprogramming.com/resources.html |
If you have an include file in a non-standard path, e.g. /opt/myincludes, you can include them with the -I option to gcc:
Code:
gcc -I/opt/myincludes -c cp.c -o cp.o Code:
gcc -I/opt/myincludes -I/opt/yourincludes ... Code:
gcc -L/opt/mylibs -lmine cp.o -o cp |
All times are GMT -5. The time now is 11:25 PM. |