Developing on a macbook

Joined
Jul 14, 2006
Messages
29
Reaction score
0
Points
1
Decided to continue what i began learning about 2 months ago, and that is the C language. So i hear that i need something called Apple Developer Tools.

After searching their site on the developer tools, i came across something called xcode 2.0 (approx. 960Mb). Is this what i need so that i can begin develpment programs on my macbook?
 
Joined
May 27, 2006
Messages
445
Reaction score
16
Points
18
Location
Concord, NC
Your Mac's Specs
Macbook Pro 17" 2.6GHz 4GB RAM
Yes- it works great.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
Xcode comes on your install disks, so you don't have to download the very latest from Apple. The downlaod requires an ADC membership of which they have a free version.
 
OP
B
Joined
Jul 14, 2006
Messages
29
Reaction score
0
Points
1
coding on mac

so i downloaded apple developer tools (Xcode 2) and installed it. I made doubly sure i had GCC 3.3 and 4.0 installed aswell as X11 but, i assume the main installer installs these rather then me having to go through every package manually.

I wrote a simple "Hello" program using the text editor "VI" in terminal. But..im a little unsure how to execute. normlly i did "a.out test" and it would compile and run..but it appears differently in OS X.

Anything im doing wrong? my code is below..but i know its rght lol..

#include stdio.h

main()
{
printf("Hello worl/n");
}
 
Joined
Feb 2, 2004
Messages
12,455
Reaction score
604
Points
113
Location
PA
Your Mac's Specs
MacBook
NOTE: Continuation of previous post. Merged threads
 
Joined
Apr 25, 2003
Messages
1,301
Reaction score
62
Points
48
Location
The home of the free and the land that did for Bra
Your Mac's Specs
24"iMac, 15"MB-Pro, MacBook, G4 iMac, PM G5 2x2Ghz, G4 iBook & Some PCs
so i downloaded apple developer tools (Xcode 2) and installed it. I made doubly sure i had GCC 3.3 and 4.0 installed aswell as X11 but, i assume the main installer installs these rather then me having to go through every package manually.

I wrote a simple "Hello" program using the text editor "VI" in terminal. But..im a little unsure how to execute. normlly i did "a.out test" and it would compile and run..but it appears differently in OS X.

Anything im doing wrong? my code is below..but i know its rght lol..

#include stdio.h

main()
{
printf("Hello worl/n");
}


a.out is the default name for the executable created by cc after it is compiled and linked.

If your source file is called test.c then try cc test.c

And it probably should be #include "stdio.h"

Oh and you left the d off of "world". ;)

Amen-Moses

(edited to add: Mind you, you really want to use XCode, if you have fully installed it the main XCode executable is in /Developer/Applications.

Google for XCode tutorials as well.)
 
OP
B
Joined
Jul 14, 2006
Messages
29
Reaction score
0
Points
1
ok thanks for the quick reply! I just tried what you suggested and its given me two error msgs...

i686-apple-darwin8-gcc-4.0.1: test: no such file or directory
i686-apple-darwin8-gcc-4.0.1: no input files

Opened the file using Xcode...cant build or do anything else other then edit with it. The file is saved in the same location as where ive pointed all the project files to go ... simon/Documents/C_Proj_Files
 
Joined
Apr 25, 2003
Messages
1,301
Reaction score
62
Points
48
Location
The home of the free and the land that did for Bra
Your Mac's Specs
24"iMac, 15"MB-Pro, MacBook, G4 iMac, PM G5 2x2Ghz, G4 iBook & Some PCs
ok thanks for the quick reply! I just tried what you suggested and its given me two error msgs...

i686-apple-darwin8-gcc-4.0.1: test: no such file or directory
i686-apple-darwin8-gcc-4.0.1: no input files

Opened the file using Xcode...cant build or do anything else other then edit with it. The file is saved in the same location as where ive pointed all the project files to go ... simon/Documents/C_Proj_Files


Have you got the .c on the end?

btw XCode is a full GUI development tool, you really need to read a tutorial on it.

Amen-Moses
 
Joined
Apr 25, 2003
Messages
1,301
Reaction score
62
Points
48
Location
The home of the free and the land that did for Bra
Your Mac's Specs
24"iMac, 15"MB-Pro, MacBook, G4 iMac, PM G5 2x2Ghz, G4 iBook & Some PCs
yes, the file is called.. "test.c"

Well in that case ...

cc test.c

followed by (assuming no errors) ...

./a.out

Should do the trick if everything is installed correctly.

(Oh and you have to be in the same directory as the test.c file but I assumed that was obvious.)

Amen-Moses
 
Joined
Jan 4, 2006
Messages
1,385
Reaction score
146
Points
63
Location
Hamburg, Germany
Your Mac's Specs
MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
In Terminal
test.c
#include <stdio.h>

int main()
{
printf ("Hello World\n");

}

$gcc -o test test.c ---> to create an execution file.

$./test --->to execute
 
OP
B
Joined
Jul 14, 2006
Messages
29
Reaction score
0
Points
1
i just get the message from bash that "-o command not found"

UPDATE: seemed to work eventually. i just moved the file from location..replaced it and it seemed to work. TY for help
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top