Fedora Linux Support Community & Resources Center
  #1  
Old 5th August 2012, 07:07 AM
Bosscheesemo Offline
Registered User
 
Join Date: Aug 2012
Location: Nebraska
Posts: 5
linuxfirefox
Arrow Beginning to program in C in Linux

Hello everybody! I'm new to the world of Linux and I'm still getting used to things and how linux works. I like it a lot so far, but I have some questions about programming.

I'm not a complete programming noob- I've done some work with programming PIC18 microcontrollers using machine assembly code and I'm interested in learning C. I'm used to using Microchips IDE, so I'm accustomed to a fairly straightforeward programming environment where I enter code, hit a compile/run button, and see what happens. I want to move up to programming a computer rather than a microcontroller, and though I'd fully believe a computer could be programmed with machine assembly code, I'd rather not be the guy stuck with that job.

First off, is there a programming environment that does that in linux? If not could someone point me in the direction of some good C programming software? At the moment I'm stuck with this thing called VIM so at the very least I'd like to know how to execute code I've written in VIM. I guess I'm essentially asking how I get started. Just give me all the software and the knowhow I need to get the words "Hello World!" to pop up on screen and I can take it from there.

Second, assuming I manage to get a message of my choosing to pop up on screen, what sort of things can knowledge of C programming do for me? Something I think would be nice is a program that automatically says "Yes" when my antivirus asks me If I wnat to conduct a scan. What other possibilites are there for me?

Third (and this is a bit off topic I know but this has been annoying me a bit for some time now) how do I change the background of Fedora 17's user loggin screen? The default is some fireworks in the sky, but I'm getting rather tired of seeing the same thing at the loggin and not knowing how to do anything about it.


Thanks everybody!!
Reply With Quote
  #2  
Old 5th August 2012, 09:21 AM
muep Offline
Registered User
 
Join Date: Jun 2006
Posts: 123
linuxfirefox
Re: Beginning to program in C in Linux

With Vim, you would just write your program into a C source file, or several of them.

If you wrote a simple program into a file called hello.c, you could compile and run it outside Vim like this:

Code:
gcc hello.c -o hello
./hello
For more complex programs, you might use GNU Make or some other tool to automate the compiler invocations, because multi-file programs often take some more steps to build.

There are more integrated enviroments like Eclipse and Qt Creator in Fedora. However, just the plain Unix-like GNU/Linux comman environment provides plenty of tools for programming in C.
Reply With Quote
  #3  
Old 5th August 2012, 10:23 AM
Fenrin Offline
Registered User
 
Join Date: Apr 2010
Location: Earth
Posts: 901
linuxopera
Re: Beginning to program in C in Linux

you could also try the codeblocks or Anjuta IDE. Both is in the fedora repository.
Reply With Quote
  #4  
Old 5th August 2012, 11:06 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,708
linuxfedorafirefox
Re: Beginning to program in C in Linux

Quote:
Originally Posted by Bosscheesemo View Post
Just give me all the software and the knowhow I need to get the words "Hello World!" to pop up on screen and I can take it from there.
For C programming I use Emacs. You can install it via yum by running this command (as root):
Code:
yum install emacs
Emacs has a "Compile" menu option which by default tries to run make. So if you have a Makefile in the current directory then that will be used. If you don't, then you can set a custom compile command (e.g. gcc -o hello hello.c) with a special commented first line in your source code file. On subsequent compilations that custom compile command will be remembered, and you'll have the option of changing it. That special first line is of the form:
Code:
/* -*- mode: c; compile-command: "whatever command(s) you want"; -*- */
Only the stuff in quotes needs changing.

For example, in the pictures below you'll see how to compile and run a "Hello, world!" C program all within Emacs:
Attached Thumbnails
Click image for larger version

Name:	emacs-compile1.png
Views:	99
Size:	30.0 KB
ID:	23578   Click image for larger version

Name:	emacs-compile2.png
Views:	93
Size:	61.7 KB
ID:	23579   Click image for larger version

Name:	emacs-compile3.png
Views:	90
Size:	33.0 KB
ID:	23580   Click image for larger version

Name:	emacs-compile4.png
Views:	93
Size:	54.6 KB
ID:	23581  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #5  
Old 6th August 2012, 01:05 AM
Bosscheesemo Offline
Registered User
 
Join Date: Aug 2012
Location: Nebraska
Posts: 5
windows_7ie
Re: Beginning to program in C in Linux

I tried that Codeblocks environment and I think I like that. Thanks for the help! I'll make sure to ask you fine gents first int he future if I need anything! Thanks again and happy programming!
Reply With Quote
  #6  
Old 6th August 2012, 08:00 AM
pjoh Offline
Registered User
 
Join Date: Nov 2007
Posts: 84
linuxchrome
Re: Beginning to program in C in Linux

microchips new ide mplab-x is netbeans based which was in fedora last time i tried (f16) but i think i remember reading something about it being dropped.
i've just started using geany for c programming and i like it, very easy to use, describes itself as "A fast and lightweight IDE." vim and emacs good but steep learning curve.
Reply With Quote
  #7  
Old 7th August 2012, 12:08 PM
aleph Offline
Banned (for/from) behaving just like everybody else!
 
Join Date: Jul 2007
Location: Nanjing, China
Posts: 1,332
linuxfirefox
Re: Beginning to program in C in Linux

If you're going to release your code as a package that can compile on a wide variety of systems, you may also add the GNU Auto-tools to your developing environment. Red Hat has a free book on this topic http://sources.redhat.com/autobook/

But for now you can just as well postpone this topic as you're learning the basic stuff first.
__________________
Code:
from rlyeh import cthulhu
cthulhu.fhtagn()
Reply With Quote
  #8  
Old 8th August 2012, 05:22 AM
ocratato Online
Registered User
 
Join Date: Oct 2010
Location: Canberra
Posts: 1,710
linuxfirefox
Re: Beginning to program in C in Linux

Given that you come from a microcontroller background, I am assuming that you have a good grasp of variables and addresses - that will be useful when programming in C.

I spent many years maintaining 500K lines of C code with nothing more than vim and command lines programs. Until you start using large libraries I would not bother with an IDE. They often take a lot of learning to use well, and that is easier if you understand what is happening behind the scenes.

If you haven't already, get a copy of "The C Programming Language" by Kernighan and Ritchie. Its not a very big book and is quite easy to read. Work through the examples and exercises in it.

At first I would just use gcc on the command line to build the programs. Then you can automate it a bit with some shell scripting. Then move on to using the 'make' command. Later you should look at the autotools suite - its a lot of learning, but worth the effort if you want to publish your work.

For your first programs I would recommend staying away from GUIs. The C based alternatives are GTK and Motif. Both are large and complex. Once you get confortable with using libraries then perhaps move to GUI programs. An alternative is to use something like Python for the GUI interface with the work being done by your C program.

While C is a powerful language, it has its limits when trying to build large systems. For that you may want to consider moving to C++ or some other object oriented language. Something to think about in a few years time.

All the best, and drop by occasionally to let us know how you are getting on.
Reply With Quote
  #9  
Old 9th August 2012, 05:00 PM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,094
linuxfirefox
Re: Beginning to program in C in Linux

Quote:
Originally Posted by pjoh View Post
microchips new ide mplab-x is netbeans based which was in fedora last time i tried (f16) but i think i remember reading something about it being dropped.
i've just started using geany for c programming and i like it, very easy to use, describes itself as "A fast and lightweight IDE." vim and emacs good but steep learning curve.
It doesn't matter that netbeans was dropped, just get the installer file from

http://netbeans.org/downloads/

and it installs just fine. The job of updating that would usually be handled by yum can be done by netbeans itself by using the Help menu (Help -> Check for Updates).

If you install it under your home directory you can do the update yourself but if you install it in some system area like /usr/local you'd have to run it as root, do the update and then quit so you can do your work as the user.
Reply With Quote
  #10  
Old 13th August 2012, 05:59 AM
Mepoe Offline
Registered User
 
Join Date: Oct 2011
Posts: 110
linuxopera
Re: Beginning to program in C in Linux

Of course, you could build yourself a make file that's executable and then just click it when you want it... (I think...)
Reply With Quote
  #11  
Old 13th August 2012, 04:53 PM
Gareth Jones Offline
Official Gnome 3 Sales Rep. (and Adminstrator)
 
Join Date: Jul 2011
Location: Birmingham, UK
Age: 32
Posts: 2,771
linuxfirefox
Re: Beginning to program in C in Linux

Quote:
Originally Posted by Ravenshade View Post
Of course, you could build yourself a make file that's executable and then just click it when you want it... (I think...)
You could, although it'd be fairly non-standard. You'd need to add a shebang to the start of the Makefile: "#!/usr/bin/make -f" or similar.
Reply With Quote
Reply

Tags
beginning, linux, program

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux hype beginning to have an impact? Jongi Wibble 55 27th April 2008 08:43 PM
which program best to record VHS to linux Wiles Using Fedora 5 7th December 2007 03:20 PM
Q: Program like Dreamweaver for Linux aero-z Using Fedora 2 28th February 2006 06:46 PM
CPU-Z-like program for Linux? leaded Linux Chat 2 3rd January 2005 08:33 AM


Current GMT-time: 14:21 (Saturday, 22-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Korwai Instagram Photos - Quickborn Photos - Talwara