PDA

View Full Version : c environment



underskore_
24th February 2005, 06:53 AM
well ive just started doing C at uni, we are using gcc for it.
im trying to figure out how i can continue on with my class work on my powerbook.
i did a bit of searching and ended up downloading and installing xcode tools as i saw it had gcc as a component, but when i open up my source code from school all i can do in xcode is what i can do in notepad.
help plz
H

Cam
24th February 2005, 07:54 AM
Yes, xcode comes with gcc and all of its glorius libaries.

When I code, I use gedit on gnome. This isnt much help to you. But there are numurous powerful IDE's (integrated development environments) for linux that could be available for mac.

However, XCode should be all you want. It provides you with a small bit of project management. Syntax colouring. etc. etc.

What's not in XCode that you would like in another IDE?

careck
24th February 2005, 08:52 AM
You may also have a look at Apple's extensive documentation, especially concerning the XTools:

http://developer.apple.com/documentation/D...Xcode-date.html (http://developer.apple.com/documentation/DeveloperTools/Xcode-date.html)

Argh, I'm dying to get my hands wet with Objective-C and Cocoa, but still waiting for the PowerBook :(

Cheers,
Carsten.

Quamen
24th February 2005, 09:12 AM
why don't you just fire up the terminal and use gcc from the command line like I assume you are doing at uni? That's what I do.

underskore_
24th February 2005, 01:26 PM
lol gcc from command line, if i could do it i would but ive only had 1 class of it at uni so far but we are using a program called gcc im not sure what its deal is as we download it from a NZ uni but is has GUI

and the problem with xcode is that i can open my source code and stuff but it has like every option under the sun greyed out so i cant click on them, loks like ill have to a bit of research on how to use the prog.
but i ve seen something about putting gentoo onto osx so i might have a look into that as i have few nix nerd friends that would be able to help me out once i had that running.

Marlor
24th February 2005, 02:49 PM
Originally posted by underskore_@Feb 24 2005, 01:26 PM
lol gcc from command line, if i could do it i would but ive only had 1 class of it at uni so far but we are using a program called gcc im not sure what its deal is as we download it from a NZ uni but is has GUI
GCC is the GNU Compiler Collection. It is a collection of compilers (including one for C and another for C++). GCC, like most compilers is command-line only. There are many GUIs that use it, but the compiler itself doesn't have a GUI.


and the problem with xcode is that i can open my source code and stuff but it has like every option under the sun greyed out so i cant click on them, loks like ill have to a bit of research on how to use the prog.
I haven't used Xcode much (in fact, not at all for C coding), but I assume your problem is that you haven't created a project.

Create a new project by choosing the menu item "File->New Project" (use the type "Command Line Utility/Standard Tool"). Give it a name (e.g. "Test"), then use something like "~/projects/Test" as the project directory. It should automatically create a "main.c" file. You can then paste your code into this, or copy your existing files into the project by using the "Project->Add to Project" menu item. I'd advise you to tick the "Copy items into destination group's folder" box when you do this, so all your files are in one place. Once you've done this, you should be able to use all the fancy menu options.

Since you're just starting coding, I'd really advise you to use a plain old text editor, though. You will learn a lot more by using the command-line tools... deciphering the compiler's error messages is an essential skill. I'm a Java coder, and I use JEdit for coding quick utilities, but it will probably have a syntax-highlighting mode for C too. Emacs is a good choice if you are willing to learn its esoteric commands: it is quite powerful, and there are some nice "Aquafied" versions floating around.

All in all, I'd advise you to become comfortable with the command line if you want to do coding.


but i ve seen something about putting gentoo onto osx so i might have a look into that as i have few nix nerd friends that would be able to help me out once i had that running.
Have a look at Fink if you want a full suite of Unix utilities. OS X is Unix, and Fink simply makes it easy to install a wide range of Unix utilities on your Mac.

Cam
24th February 2005, 07:14 PM
Easy,

If your just making a simple C program without any special libaries.

gcc <filename.c> -o <output_file>

This will compile filename.c into output_file. Then just run output_file by typing ./output_file.

But. You dont need to do that do you? XCode does that for you.. I think..

Cam
24th February 2005, 07:18 PM
Originally posted by Marlor@Feb 24 2005, 02:49 PM
Have a look at Fink if you want a full suite of Unix utilities. OS X is Unix, and Fink simply makes it easy to install a wide range of Unix utilities on your Mac.
vim for text mode, comes with mac os x.

um, i stombled upon something while looking for a mono IDE for aqua..

Its called The Eclipse Project. Its a platform independant IDE that uses modules to control what language you are coding in.

The URL is: http://www.eclipse.org

Just make sure, when you make it big in the programming world, you think back to your beginnings, your true unix and open source heart.. take a little give a little you know what i mean? ;-)

Cam
24th February 2005, 07:21 PM
Oh, the project is &#036;40 million dollar sponsered by IBM. Its built in Java. And has support for alot of languages, (including java ofcourse)

sfcoy
24th February 2005, 07:24 PM
A good place to start in xcode is to use the "New Project..." wizard to create a new command line tool (try "Standard Tool") and then work from there.

Your souce code will be syntax coloured and you can build and debug.

Steve C.

Marlor
24th February 2005, 10:24 PM
Originally posted by Cam@Feb 24 2005

gcc <filename.c> -o <output_file>

...

But. You dont need to do that do you? XCode does that for you.. I think..
Yep, that will do it alright, and it would be much better to learn how to use gcc than to use Xcode. We actually discourage the use of GUI IDEs in first year CompSci subjects at the Uni where I work. Learning how to use compiler flags and decipher error messages is just as important a skill as learning the language syntax.


Its called The Eclipse Project. Its a platform independant IDE that uses modules to control what language you are coding in.
Eclipse is a marvellous piece of software that has excellent support for refactoring code and a great plugin architecture, but just like all project-based IDEs, it is overkill when there are only a few files in your project.


vim for text mode, comes with mac os x.
Them&#39;s fighting words... Emacs all the way. Actually, if you want a real man&#39;s editor, open up the OS X terminal, and try ed (http://www.gnu.org/fun/jokes/ed.msg.html)&#33; But seriously, emacs and vi are great editors, I have used both extensively (and prefer emacs), but most people don&#39;t want to spend a couple of days learning a new set of keybindings, so I usually recommend jEdit (at least for Java development, but it should be fine for C)... since it is simple, configurable, and has an excellent code folding and plugin system. It is even better on OS X, since it integrates with the Aqua look and feel reasonably well.

Quamen
24th February 2005, 10:24 PM
Originally posted by underskore_@Feb 24 2005, 01:26 PM
lol gcc from command line, if i could do it i would but ive only had 1 class of it at uni so far but we are using a program called gcc im not sure what its deal is as we download it from a NZ uni but is has GUI

Then you&#39;re not using GCC. You&#39;re using an IDE that uses GCC to do its compiling.

As stated above, in the terminal: gcc sourcefile.c -o outputfile

This will compile sourcefile.c into outputfile which is then run from the command line using ./ouputfile

It&#39;s that simple. Forget xCode. Use the command line. In the long run you will end up in a much happier place as your uni computers (asuming they are running unix) will behave the same if you stick to the command line, if you get into IDE&#39;s then it is going to feel like a whole different system from the man to the unix labs. Unless you get fink and the same IDE going on your mac.

underskore_
25th February 2005, 05:48 PM
well thanks for all the great tips, and im doing robotic engineering @ uni so coding is a major part but i still need to get off my arse and learn how to do it.
looks like ill go jump on the PB and start messing around.
oh and no unix labs for me, only windows pcs.
but a teacher i have for the coding subject is an open source man, in our first lecture he got quite worked up when talking about how a court called linux in its various forms real competition for microsoft.
H