473,748 Members | 6,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2179
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...@gmai l.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#includ e <stdio.h>\nin t 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**********@g mail.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#includ e <stdio.h>\nin t 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",m aybe 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************ **********@h54g 2000cwb.googleg roups.com>,
Bill Pursell <bi**********@g mail.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"(def ault)
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.p l
--
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

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

Similar topics

4
1587
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 line to be a closing quote mark if they are not balanced.
5
2653
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 demand for. Looking at jobs there seems to be a better chance in getting a java job rather than a oracle or c++ job. Also is java and oracle a good combiantion?
4
2267
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 port? I hope someone could help me! Thks JP
2
2479
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
3490
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 substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But on Windows, wchar_t is 16 bits which isn't enough for characters which can't be simply encoded...
15
4638
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
8
2191
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 I'll email full releases to anyone who helps FOC of course: Profile: I'm looking for someone who fits a profile - You must be willing to spend some time with the software and report back
1
1422
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 save... rep_path = "\\dotnet\etrans\mt\acsd.doc" File fso = new File(rep_path) fso.createNewFile();
1
7491
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 I had no luck. Could someone help me in achieving on Red Hat Linux server. Here is the details of my Linux server. OS: Red Hat Linux (Linux xyzsrvr 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux) Java: java version...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.