Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C

C
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Bend, OR, U.S.A.
Status: Offline
Reply With Quote
Jun 1, 2002, 10:46 PM
 
Ok, here is my dillema. I'm trying to learn C and use Apple's Project Builder. But i cannot figure out how to compile with it. Any help would be great. I'm very new to programming btw.
     
Junior Member
Join Date: May 2002
Location: Australia
Status: Offline
Reply With Quote
Jun 2, 2002, 02:52 AM
 
I am in the same boat as you. I too cannot get Project Builder to built C files.

So I use the terminal to compile.

cd /name/ofthedir/
cc -o appname HelloWorld.c

this will produce the appname program wich you can run by typing ./appname
     
Forum Regular
Join Date: Mar 2002
Location: Düsseldorf, Germany, Europe, Earth
Status: Offline
Reply With Quote
Jun 2, 2002, 05:24 AM
 
Command line is how I usually compile short Ansi C programs. However if you really want the comfort of Project Builder, create a project file by selecting "New Project" from the file menu, and in the assistent that pops up, scroll all the way down until you find "Standard Tool" (it is in the tools section, so you might have to click the diclosure triangle next to "Tools" if it's not shown). This works on the april beta dev tools, but I suppose it's the same in other versions, too.
PB creates a new main.c file (which defaults to the usual Hello World program) that you can then edit. Compile and run it by clicking the Hammer and Computer Screen button, your new program's output will appear in the Project window.

HTH, Seb.
     
Fresh-Faced Recruit
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 2, 2002, 05:24 AM
 
Have you guys tried making Project of type "C++ Tool"? Obviously, it's not straight C, but I think it would work for you.

Edit: OK, Seb G, what's the difference between "C++" and "Standard" Tools? is "Standard" straight C?

<small>[ 06-02-2002, 06:30 AM: Message edited by: serversurfer ]</small>
Love,
The Surfer
     
Forum Regular
Join Date: Mar 2002
Location: Düsseldorf, Germany, Europe, Earth
Status: Offline
Reply With Quote
Jun 2, 2002, 05:48 AM
 
Yes, "Standard" is plain C.
     
mattpen  (op)
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Bend, OR, U.S.A.
Status: Offline
Reply With Quote
Jun 2, 2002, 10:16 AM
 
thanks seb j, that seemed to work. I'll have to play around with it until i'm sure but thanks.
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Texas
Status: Offline
Reply With Quote
Jun 4, 2002, 01:41 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by dogwood:
<strong>I am in the same boat as you. I too cannot get Project Builder to built C files.

So I use the terminal to compile.

cd /name/ofthedir/
cc -o appname HelloWorld.c

this will produce the appname program wich you can run by typing ./appname</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I am also trying to learn C, but I am not using PB. From the terminal shouldn't the compile command be gcc? Everything I have read says Apple's compiler is based on gcc, but when I try to use it, it returns file not found. I have not tried just cc, but I will now.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 4, 2002, 02:04 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by jcopeland:
<strong>From the terminal shouldn't the compile command be gcc? Everything I have read says Apple's compiler is based on gcc, but when I try to use it, it returns file not found. I have not tried just cc, but I will now.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">cc IS gcc. As of the April 2002 DevTools, both "cc" and "gcc" work, I think.
     
Professional Poster
Join Date: Apr 2001
Location: Seattle, WA
Status: Offline
Reply With Quote
Jun 13, 2002, 01:09 PM
 
guys, there's a tweak w/ PB and C code (unless it's been updated recently), that makes actually running C code pretty much futile, in it.

#1, make your project a Standard Tool, when you create the Project Space, that'll allow you straight C code, instead of C++.

#2, when you compile and run your code, it won't seem like it works. Feed it all the inputs you ask for in the code. after it get's all the inputs, it'll spit out all the outputs.why? I have NO clue. but, it does.

Solutions:
A. run the code using the debugger. The debugger runs everything in the right order.

B. Command line. use it, bond with it, it is your friend. learn Vi, or emacs, or any of the bazillion other command line text editors that exist. Compile in command line, using gcc (cc didn't work w/ 10.1.4, haven't tried after the latest update). if you type gcc main.c it'll create an a.out file in the same directory. use -o, it'll be named something else. run by typing ./a.out. g'luck, guys
The short shall inherit the earth. Just you wait. You won't see us coming. We'll pop out from under tables, beds, and closets in hordes. So you're tall, huh? You won't be so tall when I chew off your ankles. Mofo
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:18 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2