Nirjhar Oberoi napisa³(a):
I am new to Linux and wanted to know how to use GCC to Compile the Code
written in C? I dont want to use EMacs or VI for my editor. Can you
suggest a good IDE for linux for C Programming..
I don't use an IDE. Using gcc is fairly simple. As for my editor
preference, I usually use joe. It has a built in function to compile the
code using compiler specified in the configuration, but I don't even use
that. Simply open 2 terminal windows, joe with the code in one window,
shell in the other. Save your file from the editor, then type in the
other window: "gcc file.c" - this is the simplest form of using gcc.
Repeat this until you get rid of compile errors ;-). It compiles and
links your program and puts the executable into the file "a.out". Then
you can run it by typing "./a.out". If you want to change the
executable's name, use "gcc -o outfile file.c", then your executable
will be named "outfile".
To compile a program consisting of several source files, you can type
"gcc -o outfile file1.c file2.c file3.c". You can also compile each
module individually (with the command like "gcc -c -o file1.o file1.c" -
the "-c" flag means compile only, do not link) and then link them with
"gcc -o outfile file1.o file2.o file3.o". You can probably figure out by
yourself various mixtures of these methods... ;-)
For more information, read the manual with "man gcc" - be warned,
there's LOT of options (most of them although you will never use). -I,
-L and -l are the most important ones. -I specifies the additional
locations for include files, -L the same for library files, -l tells the
linker what libraries to link (standard library doesn't need to be
specified).
So, for example
gcc -o test main.c common.o mystring.o -I ./include -lnsl
will compile the file "main.c", link it with object files "common.o" and
"mystring.o" and with the library named "nsl", and put the executable
into the file "test". Include files will be searched - beside standard
locations - in subdirectory "include" of the current directory.
Hope this helps.
Does C Programming on windows environment and on linux environment
differ???
Library functions differ (except for the standard library - printf,
scanf etc., which should be the same on both platforms), not the
language itself. It depends on what libraries you were using in Windows.