# How do I link to frameworks from command line compile?



## rharder (Nov 6, 2002)

I have a short program with a few lines all in main(...) that uses NS... classes and AB... classes (address book api). How do I compile it from the command line (instead of project builder)?

I would expect to see something like

```
gcc -framework Foundation.framework:AddressBook.framework main.m
```
or something, but of course that syntax doesn't work. If I just say "gcc main.m" I get this:


```
% [b]gcc main.m[/b]
ld: Undefined symbols:
.objc_class_name_ABAddressBook
.objc_class_name_NSAutoreleasePool
.objc_class_name_NSConstantString
.objc_class_name_Utility
_NSLog
__NSConstantStringClassReference
_kABAddressHomeLabel
_kABAddressProperty
_kABAddressWorkLabel
_kABFirstNameProperty
_kABLastNameProperty
_objc_msgSend
```
-Rob


----------



## Ghoser777 (Nov 11, 2002)

gcc -o main.o main.c -framework Foundation

That should do the trick.

Matt


----------



## rharder (Nov 15, 2002)

Thanks. That did it, and I could add frameworks like this:
	
	



```
% [b]gcc main.m -framework Foundation -framework AddressBook[/b]
```
-Rob


----------

