Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
Hey guys. Maybe you can help me out. I signed up for a C Programming course for college. The teacher has no idea about macs and said to use the terminal. I need a stable free C/C++ Compiler. The one he recommends for XP is http://www.bloodshed.net/devcpp.html (DEV C++) but it doesn't come for OSX. Can someone help me out so I can have a visual Run/Compile/Save application compatible for C and C++. Thanks again.
Joe
 

kpua

macrumors 6502
Jul 25, 2006
294
0
Well, pretty much the only free compiler for OSX is gcc. Thank goodness it's a pretty darn good compiler and you already have it if you installed the developer tools on your Mac. You can then use Xcode as a front end for it if you're not used to using the command line.
 

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
Can you tell me how I can get to this and access it? I do not see it. Thanks. Is there really no open source compiler comparable to XP ones? That is surprising.
 

Josh

macrumors 68000
Mar 4, 2004
1,640
1
State College, PA
macbookpro10 said:
Can you tell me how I can get to this and access it? I do not see it. Thanks.

One of your Tiger install CD's should have the developer tools package on them (not sure if the CD is specifically labled or not).

Just install that package, and it will install GCC (Gnu C Compiler), XCode, Interface Builder, and some other things.

If the CD is not labeled, I'm thining it might be CD #2 (not sure, because I'm not at home right now).
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Just go to connect.apple.com, make a free account, login and download Xcode 2.4 which includes GCC 4 and GCC 3, which is all you need to get started :)
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
macbookpro10 said:
Can you tell me how I can get to this and access it? I do not see it. Thanks. Is there really no open source compiler comparable to XP ones? That is surprising.
gcc is an open source compiler, available for OS X, Linux and XP (via cygwin or MinGW) and other *nixes. It's pretty much standard for open source development.
 

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
plinden said:
gcc is an open source compiler, available for OS X, Linux and XP (via cygwin or MinGW) and other *nixes. It's pretty much standard for open source development.

OK I am a total noob at this. I downloaded the file from apple's website. Installed XcodeTools.mpkg and the gcc 4 package. Now what do I do?
I ran XCode and said new project which C do I use (Carbon C++ App, Carbon C++ Standard App, C++ Tool, C++ Dynamic Library, Standard Dynamic Library)

Also, how do I open gcc? Thanks.

Joe
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
If you're following your teacher using the command line, the best thing to do is just open Terminal. XCode is really for building GUIs and you won't learn a lot about the inner workings of C using it.

Type "which gcc" and it will tell you whether it's installed correctly:
Code:
which gcc

Create a subdirectory, e.g. projects and cd to it:
Code:
mkdir projects
cd projects

Look for examples of simple C programs (everyone does HelloWorld.c), and compile and run it (the following is the simplest way of compiling and writes the program executable to a.out):
Code:
gcc HelloWorld.c
./a.out
 

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
Thanks a lot everyone (esp plinden) . I am going to have to play around with this. Although, I am still kind of dissapointed that I had to download this whole big Xcode developers suite if I just needed a C Compiler. I still really wanted one like DevC++ on XP. That is what my teacher is using, he is not using the command prompt and I dont want to use the terminal. Something basic but gets the job done. XCode has a lot of stuff I really don't need. If there is anymore input I would definately appreciate it. Thanks.
Joe
 

steelphantom

macrumors 6502a
Oct 15, 2005
555
1
macbookpro10 said:
Thanks a lot everyone (esp plinden) . I am going to have to play around with this. Although, I am still kind of dissapointed that I had to download this whole big Xcode developers suite if I just needed a C Compiler. I still really wanted one like DevC++ on XP. That is what my teacher is using, he is not using the command prompt and I dont want to use the terminal. Something basic but gets the job done. XCode has a lot of stuff I really don't need. If there is anymore input I would definately appreciate it. Thanks.
Joe

If all you're looking for is a simple C/C++ compiler, try CPP Edit. It's great for simple one-file programs, especially if you don't want to use the terminal.
 

slb

macrumors 6502
Apr 15, 2005
473
345
New Mexico
macbookpro10 said:
Can you tell me how I can get to this and access it? I do not see it. Thanks. Is there really no open source compiler comparable to XP ones? That is surprising.

GCC is the same compiler used by Dev-C++. Dev-C++ uses MinGW, a Windows port of the GNU tools, which includes GCC.
 

kpua

macrumors 6502
Jul 25, 2006
294
0
If you're just writing simple C++ apps, just create a "C++ tool" within Xcode. Unless there are some special libraries that come with that Dev-C++ thing you're talking about you shouldn't have any trouble following along with your teacher.

You don't have to use the command line at all this way and you get nice things like auto-completion and project management. But if you don't want any of those features, you can just ignore them. You can just use the text editor and the "Build" button.

And I disagree with the idea that Xcode is mainly for GUI development. I've done a fair amount of work in it that doesn't involve building GUI's at all.
 

iUserz

macrumors member
Aug 14, 2006
49
0
gcc is the compiler. There are any number of editors you can use, such as xcode, cpp edit, and many others. But don't confuse your terminology, gcc is a compiler, you now are looking for an editor :)

Dev C++ is also an editor, it uses gcc as its compiler.
 

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
iUserz said:
gcc is the compiler. There are any number of editors you can use, such as xcode, cpp edit, and many others. But don't confuse your terminology, gcc is a compiler, you now are looking for an editor :)

Dev C++ is also an editor, it uses gcc as its compiler.

Haha, oh dang. OK, I know I was missing something. I am looking for a editor than. I will try that cpp edit. Thanks again.

So I guess the question is:

What is the best C editor? Thanks.

Joe
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
macbookpro10 said:
Haha, oh dang. OK, I know I was missing something. I am looking for a editor than. I will try that cpp edit. Thanks again.

So I guess the question is:

What is the best C editor? Thanks.

Joe
Xcode! You're welcome :).
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
TextWrangler is a pretty decent, flexible code editor, and it's free. There are lots of others available, but that's a good place to start (it's just a text editor so you'd still be using Terminal to compile and run your files). Xcode is good too, but there's a bunch of overhead involved in using that, as you've discovered already. If you're writing simple one-file text-based apps, Xcode is probably overkill.
 

macbookpro10

macrumors newbie
Original poster
Jun 7, 2006
23
0
HiRez said:
TextWrangler is a pretty decent, flexible code editor, and it's free. There are lots of others available, but that's a good place to start (it's just a text editor so you'd still be using Terminal to compile and run your files). Xcode is good too, but there's a bunch of overhead involved in using that, as you've discovered already. If you're writing simple one-file text-based apps, Xcode is probably overkill.

Exactly! Thank you very much, this is all I needed. Thanks again everyone.
Joe
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
I usually prefer using the command line for working with C files. Xcode is fantastic for making GUI apps, but I just could never figure out a good way to make it compile straight-up C code with no bullsh*t. For the C course I took two years ago, I didn't want .h files or templates with #include <helloworld.h>. I just wanted a blank text file that would compile as C code and display results in another window, without having to create a whole project for it.

I would love to use Xcode for compiling C, but it just seems like overkill. Can anyone suggest a way to make Xcode work that way, or should I stick with the terminal? (I have no beefs with the terminal at all...just looking for other options too)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
elfin buddy said:
I usually prefer using the command line for working with C files. Xcode is fantastic for making GUI apps, but I just could never figure out a good way to make it compile straight-up C code with no bullsh*t. For the C course I took two years ago, I didn't want .h files or templates with #include <helloworld.h>. I just wanted a blank text file that would compile as C code and display results in another window, without having to create a whole project for it.

I would love to use Xcode for compiling C, but it just seems like overkill. Can anyone suggest a way to make Xcode work that way, or should I stick with the terminal? (I have no beefs with the terminal at all...just looking for other options too)
File > New Project > C++ Tool.. then edit and build.
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
kainjow said:
File > New Project > C++ Tool.. then edit and build.

Nope, that ain't gonna do it. As I said above,

elfin buddy said:
I just wanted a blank text file [...] without having to create a whole project for it.

It creates a project folder, a .xcodeproj file, and fills the .cpp file with this:

Code:
#include <iostream>

int main (int argc, char * const argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}

Sorry, but not what I was looking for :eek:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.