PDA

View Full Version : Best C Complier for OSX?




macbookpro10
Aug 24, 2006, 11:50 AM
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
Aug 24, 2006, 11:54 AM
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
Aug 24, 2006, 12:04 PM
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
Aug 24, 2006, 12:08 PM
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
Aug 24, 2006, 12:23 PM
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 :)

almightyshoe
Aug 24, 2006, 12:23 PM
When in doubt, gcc all your projects. It looks like XCode has it.

GFLPraxis
Aug 24, 2006, 12:57 PM
Use XCode, or gcc via terminal.

plinden
Aug 24, 2006, 01:27 PM
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
Aug 24, 2006, 01:35 PM
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
Aug 24, 2006, 01:42 PM
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:
which gcc

Create a subdirectory, e.g. projects and cd to it:
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):
gcc HelloWorld.c
./a.out

macbookpro10
Aug 24, 2006, 01:54 PM
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
Aug 24, 2006, 02:53 PM
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 (http://www.macupdate.com/info.php/id/18943). It's great for simple one-file programs, especially if you don't want to use the terminal.

slb
Aug 24, 2006, 03:33 PM
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
Aug 24, 2006, 04:31 PM
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
Aug 24, 2006, 04:58 PM
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
Aug 24, 2006, 05:18 PM
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
Aug 25, 2006, 07:53 AM
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 :).

Palad1
Aug 25, 2006, 08:35 AM
let's just say it starts with V and ends with I

:X!

kainjow
Aug 25, 2006, 09:24 AM
let's just say it starts with V and ends with I

:X!
Not realy the best choice for a beginner programmer ;)

HiRez
Aug 25, 2006, 09:48 AM
TextWrangler (http://www.versiontracker.com/dyn/moreinfo/macosx/18529) 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
Aug 25, 2006, 09:51 AM
TextWrangler (http://www.versiontracker.com/dyn/moreinfo/macosx/18529) 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

bousozoku
Aug 25, 2006, 10:13 AM
let's just say it starts with V and ends with I

:X!

You're evil. :D ed would be easier.

elfin buddy
Aug 25, 2006, 10:45 AM
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 *********. 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
Aug 25, 2006, 10:56 AM
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 *********. 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
Aug 25, 2006, 11:09 AM
File > New Project > C++ Tool.. then edit and build.

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

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:

#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 :o

bousozoku
Aug 25, 2006, 11:23 AM
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 *********. 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)

Create a new project from the C tool project, remove what you don't need and save somewhere else, then, copy it into the project template folder.

elfin buddy
Aug 25, 2006, 11:35 AM
Create a new project from the C tool project, remove what you don't need and save somewhere else, then, copy it into the project template folder.

Hmmm...project templates, you say? Let me have a go at that...

elfin buddy
Aug 25, 2006, 11:45 AM
bousozoku, that seems to have worked very well! I still do have to create a project, but at least there aren't a million little files with weird extensions all over the place :) Also, creating a project is less painful now that there's an option called C Tool there ;) Thanks a lot!

bowens
Aug 25, 2006, 12:40 PM
I really liked Kate on Linux, but I haven't been able to find it for OS X. I really liked it because it had the terminal right there in the editor. I didn't have to switch windows back and forth to try out a change to my program. Does anyone know if it is available for OS X? Anyway, jEdit seems to be a pretty good cross-platform editor.

bousozoku
Aug 25, 2006, 01:35 PM
bousozoku, that seems to have worked very well! I still do have to create a project, but at least there aren't a million little files with weird extensions all over the place :) Also, creating a project is less painful now that there's an option called C Tool there ;) Thanks a lot!

You're welcome. You can create a few project templates that you would re-use often. It's always helpful to keep certain libraries connected and then, add in the extra pieces you need later.

It's always nice when your work environment is streamlined. :)

weg
Aug 25, 2006, 01:56 PM
What is the best C editor? Thanks.



Never ever ask this question when UNIX folks are around!
Well, you're in a forum where people use Mac OS X, so I guess it's too late..

Let's start the vi (comes with every Mac) vs. Emacs (http://www.apple.com/downloads/macosx/unix_open_source/carbonemacspackage.html)
war begin ;-)

With respect to best compiler: That's probably the Intel C++ (http://www.intel.com/cd/software/products/asmo-na/eng/compilers/270528.htm) compiler, since it supports OpenMP and therefore allows you to optimize your Code for the Core Duo. However, since you obviously need the compiler for an introductionary course, ANY compiler will do, and, as many others mentioned before, gcc comes for free with XCode (which you probably got with your Mac on the CD with additional programs, but it's better to download (http://developer.apple.com/tools/xcode/) the newest version for free).

gnasher729
Aug 25, 2006, 02:40 PM
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

Why don't you just use the compiler and the development system that Apple uses to build absolutely everything that your Macintosh ships with? That would be XCode then.

live4ever
Aug 25, 2006, 04:19 PM
TextMate is also a real nice text editor (not free though).

savar
Aug 26, 2006, 09:46 AM
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

I think you're confused. DEV C++ is an IDE, not a compiler. IDE=Integrated Development Environment. Usually that might include a source code editor, a way to execute the compiler from within the graphical environment, visual debugger, and SCM (source code management) interface. It used to be that all of these tools were available only separately. You'd run a text editor (like vi), then you'd close out of that and run the compiler. If the code didnt' work you'd run the debugger. Then when everything was good you'd run SCM to check in your code. Nowadays (actually the last 20-30 years probably), all of these tools can be accessed from within one application, called an IDE.

Now then, as an IDE, DEV C++ doesn't actually compile code. It also probably doesn't actually do any debugging or SCM -- it is just a text editor with front ends to all of those programs that make them conveniently accessible and often easier to use. If you read their web page, they compiler they ship with is GCC.

Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler.

Now, GCC is an open source compiler that happens to be pretty good. It's not a speed demon, but it has lots of features and runs on a dizzying array of heterogenous platforms. If you learn gcc you will learn to operate in a lot of environments. GCC is, of course, included with OS X. In fact, it is included with most unix or linux style operating systems.

Are you a comp-sci major? Or is this intro to programming for non-majors? The reason that I ask is if you are a major, you should not be learning to develop in an IDE using a visual debugger, etc. You should be learning how code is actually compiled and linked, and an IDE glosses over all those details. Furthermore, I can't imagine why a university professor is suggesting his students pay for a small-time IDE when there are free IDEs out there that are probably much better. Even the name -- bloodshed -- seems inappropriate for a professor to be asking his students to download it.

Long and short of it: think about looking for a new prof. This doesn't know anything about macs, he's already confused you about the difference between an IDE and compiler (or he's confused himself). I don't think you're going to get much out of a class like that.

bousozoku
Aug 26, 2006, 10:03 AM
Never ever ask this question when UNIX folks are around!
Well, you're in a forum where people use Mac OS X, so I guess it's too late..

Let's start the vi (comes with every Mac) vs. Emacs (http://www.apple.com/downloads/macosx/unix_open_source/carbonemacspackage.html)
war begin ;-)

With respect to best compiler: That's probably the Intel C++ (http://www.intel.com/cd/software/products/asmo-na/eng/compilers/270528.htm) compiler, since it supports OpenMP and therefore allows you to optimize your Code for the Core Duo. However, since you obviously need the compiler for an introductionary course, ANY compiler will do, and, as many others mentioned before, gcc comes for free with XCode (which you probably got with your Mac on the CD with additional programs, but it's better to download (http://developer.apple.com/tools/xcode/) the newest version for free).

emacs comes with the developer tools so it's as available as vi. It's a bit easier to use, though, especially since these days it has menus.

Xcode is nice but it's a little daunting for people new to programming.

Palad1
Aug 26, 2006, 05:34 PM
remember, with emacs,
Control X then control S : saves
Control x then control f : open a file
control x then control c : close emacs
control s then type something : search for 'something' in the current file.

When nothing seems to respond: control-g

Emacs is a bit hard for a newbye, I think XCode or textwrangler are still the best options.

Fairly
Sep 24, 2006, 06:28 PM
You have a free compiler on there already. Use it!