PDA

View Full Version : doing C


rans6andrew
23rd Sep 2010, 14:55
some years ago, in a previous life, I dabbled in C programming on a Sun Unix workstation. Got to the point where I could solve mathematical brain teasers, write "hello whirled" on the screen and sort a file to count all of the 4 letter words etc.

More recently I have been writing C for a PIC microcontroller and didn't find it too steep a learning curve.

Anyway, I run Ubuntu10 on my desktop machine and I understand that this was written in C. Also, it would seem likely that there is some C compiler available with my Ubuntu install.

I have a simple text editor (gedit) and can write the text. Does anyone know how to inspire the compiler (if there is one buried in Ubuntu) to turn my text into an executable code?

Thanks,

Rans6...

mixture
23rd Sep 2010, 15:03
I don't do Ubuntu, but I do other *nix/*nux and would assume the answer would be the same....

Have you not discovered gcc/make & friends ?

(i.e. already there, under your nose - "whereis/apropos/find make" - unless it's like SuSe which does not always automagically select "compiler tools" category during install :cool:)

For more detailed compiler tutorial, see Google "ubuntu hello world c"

Good luck, and happy coding ! :ok:

izod tester
23rd Sep 2010, 19:37
A standard Ubuntu install usually includes gcc. A good intro to compiling applications from source code is at:

https://help.ubuntu.com/community/CompilingEasyHowTo

Of course that article assumes you want to compile source code you obtain from somewhere else, whilst you intend to roll your own!

Simonta
23rd Sep 2010, 19:40
You might want to try Eclipse? It's a complete IDE. A pig to use but at least better than the command line.

Eclipse IDE for C/C++ Developers | Eclipse Packages (http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliosr)

bnt
23rd Sep 2010, 21:03
I did a basic C / C++ course at university, and compiled some of my programs on this Ubuntu Netbook. The base compiler is called gcc, but I don't think it is installed by default, since it pulls in a bunch of other stuff too. If not, just do a "sudo apt-get install gcc" to install it.

With this code in hello.c:
/* hello.c: display a message on the screen */

#include <stdio.h>

main()
{
printf("hello, world\n");
}
you compile it with gcc -o hello hello.c
and run it with command
./hello

NB: the -o parameter sets the output executable name. If you're writing C++, use g++ instead of gcc, but I generally used g++ for everything, even plain C.

Gertrude the Wombat
23rd Sep 2010, 22:18
You might want to try Eclipse? It's a complete IDE. A pig to use
Too true.
at least better than the command line
Well, possibly, on a good day.

Everybody I know who's tried both reckons Visual Studio to be miles and miles ahead. Sometimes you get what you pay for.

cats_five
24th Sep 2010, 04:16
Too true.

Well, possibly, on a good day.

Everybody I know who's tried both reckons Visual Studio to be miles and miles ahead. Sometimes you get what you pay for.


The various Visual Studio Express editions are free - but of course not available on Ubuntu etc.

Simonta
24th Sep 2010, 10:42
Well, possibly, on a good day.

Yeh, fair comment.

Everybody I know who's tried both reckons Visual Studio to be miles and miles ahead. Sometimes you get what you pay for.

I use both pretty much everyday and VS is way ahead. I reckon I get 2-3 times as much code cut in VS than in Eclipse. I looked into reconfiguring VS for Android development but there is so much I'd lose (like IntelliSense) that I might as well continue to struggle in Eclipse. Oh, the pain. Eclipse AND Java - yeuch.

If only googoo would build the ADT for VS - reckon they'd do themselves a favour by opening up a far more competent IDE to a new set of devs.

I would pay serious money for an IDE for Android.

rans6andrew
24th Sep 2010, 12:34
ta everyone, looks like the weekend might give me a break to get stuck in. Fingers crossed.

Rans6..

batninth
24th Sep 2010, 20:19
Hi Rans6...

You may need to download the various development tools on Ubuntu, but the Synaptic Package Manager will take care of all that for you. I tend to go into Synaptic then use the Search & look at what's available. Synaptic will install any dependencies as well.

The Ubuntu repositories also have a few IDEs available, again downloadable via Synaptic. I see some mention of Eclipse elsewehere, but I'd suggest you take a look at NetBeans which has a number of tutorials on the NetBeans web site.

If you are interested in erring towards the Microsoft way, then Mono is also available via Synaptic. Mono, which has its roots in Novell (but MS have a hand in it) is a .NET(-ish) implementation on Linux and includes a C# compiler.

Finally there are some good online books around, the "Think like a Computer Scientist" series are around in various places, and Bruce Eckel books include a C one somewhere

Anyway, have fun

Gertrude the Wombat
24th Sep 2010, 22:16
Eclipse AND Java - yeuch
Yeah .... :*:*:* ... trouble is that's mostly what I get paid for these days.

Never mind, there's someone wanting to pay me to spend Sunday writing C++ with VS ... now is that a :) or :* I wonder ...

Wha'ever, if I do some weekend work at least I don't get complained at about how much I spend on flying, for a little while at least.

bnt
26th Sep 2010, 00:10
IDE? Pshaw! All you need is gedit, g++, and a web browser open to cplusplus.com - The C++ Resources Network (http://cplusplus.com/). You may as well go straight to the C++ compiler, even if you write plain C and don't hold with that fancy object-orientation stuff. :8