473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need your HELP: C in LINUX

Hi,

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..

Does C Programming on windows environment and on linux environment
differ???

Thank you.

Keep Rocking

Nov 24 '06 #1
17 2141
Nirjhar Oberoi said:
Hi,

I am new to Linux and wanted to know how to use GCC to Compile the Code
written in C?
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -o foo foo.c
I dont want to use EMacs or VI for my editor.
Fine, so don't do that.
Can you
suggest a good IDE for linux for C Programming..
Linux *is* an IDE for C programming.
Does C Programming on windows environment and on linux environment
differ???
No. C is a portable language. If you confine yourself to the C language and
standard library, you will have no difficulty getting your C programs to
work on either platform.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 24 '06 #2


On Nov 24, 10:48 am, "Nirjhar Oberoi" <nirjha...@gmail.comwrote:
Hi,

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.
As a beginner you may find it somewhat awkward to use "vi" editor. But,
"vi"
is a powerful tool that enables fast, simple and effective editing of
files.
It provides certain commands that are in particular helpful when you
are
writing/reading a c program.
However, if you dont want to use it for any reason, there are text
editors
available on linux systems.

Nov 24 '06 #3

Nirjhar Oberoi wrote:
>
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..

Does C Programming on windows environment and on linux environment
differ???
Your choice of editor has nothing to do with compilation. Programming
in windows is different from programming in linux in the same way
way that any other task is different, but the code should be
the same on both (unless you use system specific calls).

The best IDE for programming in C on linux is bash, using
vim/emacs, make, ctags/etags, and gdb. If you disregard vim/emacs
right off the bat, you are doing yourself a disservice. If you really
have a need to avoid vim & emacs, you might try ed:

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 | gcc foo.c | ./a.out

....but that's crazy talk.

Nov 24 '06 #4
"Bill Pursell" <bi**********@gmail.comwrites:
Nirjhar Oberoi wrote:
>>
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..

Does C Programming on windows environment and on linux environment
differ???

Your choice of editor has nothing to do with compilation. Programming
in windows is different from programming in linux in the same way
way that any other task is different, but the code should be
the same on both (unless you use system specific calls).

The best IDE for programming in C on linux is bash, using
vim/emacs, make, ctags/etags, and gdb. If you disregard vim/emacs
right off the bat, you are doing yourself a disservice. If you really
have a need to avoid vim & emacs, you might try ed:

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 | gcc foo.c | ./a.out

...but that's crazy talk.
Yeah,Bash,Emacs/Vim,make,ctags/etags,they are so powerful...if you do not want to use them,try "anjuta" or "kdeveloper3",maybe you will found the things what you
wanted!

Good Luck!!
--
For some reasons,my EMail had been changed to "kdr2[#]163.com" now...

NO GNUS is Bad News.

------yours Killy Draw
Nov 24 '06 #5
In article <11**********************@h54g2000cwb.googlegroups .com>,
Bill Pursell <bi**********@gmail.comwrote:
....
>The best IDE for programming in C on linux is bash, using
vim/emacs, make, ctags/etags, and gdb. If you disregard vim/emacs
There's no such thing as vim/emacs.

Given that people here have had heart attacks (and some have died as a
result) when people refer to "C/C++", I'm amazed that you would even
chance uttering such a ridiculous thing (as vim/emacs).

Nov 24 '06 #6
srj

Nirjhar Oberoi wrote:
Hi,

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..

Does C Programming on windows environment and on linux environment
differ???

Thank you.

Keep Rocking
first of all i'd recomend u 2 check out the man page for gcc.
type "man gcc" on console
you can save aafile using vi or any other text editor, save it as
"name.c"
do "cc name.c"
u'll get an output file"a.out"(default)
run it by" ./a.out"
u can rename a.out by "mv a.out newname"

or do "cc name.c -o newname"
this will create output file newname instead of default a.out

hav fun with LINUX

Nov 24 '06 #7
srj wrote:
>
.... snip ...
>
first of all i'd recomend u 2 check out the man page for gcc.
type "man gcc" on console
Who is this universal programmer named u? A U2 is an airplane,
BTW.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 24 '06 #8
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.
--
Regards,
Jaroslaw Rafa
ra*@ap.krakow.pl
--
Spam, wirusy, spyware... masz do¶æ? Jest alternatywa!
http://www.firefox.pl/ --- http://www.thunderbird.pl/
Szybciej. £atwiej. Bezpieczniej. Internet tak jak lubisz.
Nov 24 '06 #9

Jarosław Rafa wrote:
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.
--
All reply's are good... but i found yours the most informative (NO
OFFENCE guyz) :)
Thank's a lot you all... i will get back to you if i need any help...
Thanks again :)
Happy Programming

Nov 24 '06 #10
srj wrote:
Nirjhar Oberoi wrote:
Hi,

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..

Does C Programming on windows environment and on linux environment
differ???

Thank you.

Keep Rocking

first of all i'd recomend u 2 ...
First of all, I recommend you to drop these abominable abbreviations on
Usenet.

Nov 24 '06 #11
srj wrote:
first of all i'd recomend u 2
Same. They had a concert tonight and last night and they
both totally ruled.

Nov 25 '06 #12
Richard Heathfield wrote:
Nirjhar Oberoi said:
>Hi,

I am new to Linux and wanted to know how to use GCC to Compile the Code
written in C?

gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -o foo foo.c
Whoa! How often do you get useful warnings from those that you wouldn't
from simple '-ansi -pedantic -Wall -W -O2'?
>Can you
suggest a good IDE for linux for C Programming..

Linux *is* an IDE for C programming.
Well, no, Linux is merely a kernel. :-)

Granted, just about all operating systems built on Linux do come with
excellent development tools, either automatically installed or as an option.

--
Simon.
Nov 29 '06 #13
Simon Biber said:

<snip>
>>Can you
suggest a good IDE for linux for C Programming..

Linux *is* an IDE for C programming.

Well, no, Linux is merely a kernel. :-)
Understood. My use of the term is a lax one - but everybody knows what I
mean, except of course for RMS & Co.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 29 '06 #14
Simon Biber wrote:
Richard Heathfield wrote:
.... snip ...
>>
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -o foo foo.c

Whoa! How often do you get useful warnings from those that you
wouldn't from simple '-ansi -pedantic -Wall -W -O2'?
I use "-ansi -pedantic -Wall -W -Wwrite-strings -Wfloat-equal'.
This handles the silly error of attempting to alter anonymous
strings, and of testing floating equality. YMMV.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 29 '06 #15
Bill Pursell wrote:
If you really
have a need to avoid vim & emacs, you might try ed:

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 | gcc foo.c | ./a.out
You don't want to pipe the output of ed to gcc; you want to wait until
ed has exited successfully before starting gcc, otherwise the foo.c file
may not yet have been written. Similarly, you should wait until gcc has
exited successfully before starting ./a.out.

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 && gcc foo.c && ./a.out
....but that's crazy talk.
Indeed.

--
Simon.
Nov 30 '06 #16

Simon Biber wrote:
Bill Pursell wrote:
If you really
have a need to avoid vim & emacs, you might try ed:

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 | gcc foo.c | ./a.out

You don't want to pipe the output of ed to gcc; you want to wait until
ed has exited successfully before starting gcc, otherwise the foo.c file
may not yet have been written. Similarly, you should wait until gcc has
exited successfully before starting ./a.out.

echo -e "a\n#include <stdio.h>\nint main(void) { printf(\"Hello\\\n\");
return 0;}\n.\nwq foo.c\n" | ed 2>&1 && gcc foo.c && ./a.out
yes, originally I had ';' instead of '|', (which is not as correct
as '&&'), but then decided to redirect ed's error stream to
/dev/null, and thought it was clever to pipe it into gcc where
it would be ignored. Unfortunately, I then also unthinkingly
went for the symmetry and piped it into a.out, forgetting
that it would only work (assuming no errors) on the
second invocation. I foolishly hoped no-one would
catch the error... Of course, there's no need at all
for ed here. Maybe the right thing to do (well, other than
the obvious--ignoring this thread comletely! :) ) is something like

echo -e "#include <stdio.h>\nint main(v) { printf(\"Hello\\\n\");return
0;}" | sed s/v/void/ foo.c && gcc foo.c && ./a.out

--
Bill

Dec 1 '06 #17
CBFalconer wrote:
>
srj wrote:
... snip ...

first of all i'd recomend u 2 check out the man page for gcc.
type "man gcc" on console

Who is this universal programmer named u? A U2 is an airplane,
BTW.
No, no. "u" means "unsigned" and he obviously has
an unsigned constant "2". But ISTM that the "u" should
follow the constant. Anyway...

U2 is a rock group.

--
+----------------------------------------------------------------+
| Charles and Francis Richmond richmond at plano dot net |
+----------------------------------------------------------------+
Dec 1 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
I'm sure it's possible, but I can't figure it out... Given a line of text, I need to convert all of the spaces between quote marks to an underscore character. One can consider the end of the...
5
by: mr.iali | last post by:
Hi Everyone I would like to get into software developent using a programming language like c++, java or pl/sql for oracle. I have no idea where to start from. Which language is there more...
4
by: João Pires | last post by:
I have a program write in VB and I need to convert the code to C for Linux. Well, I began to do that but I have some problems ... - How can I write te code in C to comunicate with the serial...
2
by: O.R.Senthil Kumaran | last post by:
Hi list: Following is a piece of code: main(int argc, char** argv) { int rc, result; struct passwd *uidpwent; /* init resources */
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
8
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and...
1
by: gopikrishnan | last post by:
Hi...I have a problem... We are migrating windows to linux... I need a solution to create a msword document in linux. From the database.. we can get the path where the word document should...
1
by: crabbie_upk | last post by:
Hi, Need help in tuning JAVA on LINUX. From http://www.trutek.com/index.php?id=173 I understand that on Linux operating system with 4GB memory, JVM can be run with maximum memory of 3800m. But...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.