Re: libraries
Re: libraries
- Subject: Re: libraries
- From: Philip George <email@hidden>
- Date: Mon, 21 Jul 2003 06:30:37 -0500
On 7/21/03 6:16 AM, "Alastair J.Houghton" <email@hidden> wrote:
>
On Monday, July 21, 2003, at 11:11 am, Philip George wrote:
>
>
> Actually, both of these approaches yielded a library, but in both
>
> cases,
>
>
Both approaches would, but the former runs the linker over the object
>
file unnecessarily (which is why you needed the -nostdlib and -static
>
flags).
>
>
> after i added the library to my project, and tried to call the adder()
>
> function, I got an "Undefined symbols: _adder" error during the link
>
> stage.
>
>
You need to provide more information here. How did you declare the
>
adder() function? How did you add the library to Project Builder?
>
Which version of Mac OS X (and developer tools) are you using? (It
>
matters because link order was significant in earlier versions of the
>
tools, but isn't any more.) Also, I know it sounds stupid, but have
>
you checked your spelling? It's surprising how many times people miss
>
the obvious ;-)
>
>
Kind regards,
>
>
Alastair.
[xxxxx:~] user% pico adder.c
UW PICO(tm) 2.5 File: adder.c Modified
int adder(int a, int b);
int adder(int a, int b) {
return (a+b);
}
[ Wrote 6 lines ]
[xxxxx:~] user% gcc adder.c -c -o adder.o
[xxxxx:~] user% ar -r mymathlib.a adder.o
ar: creating archive mymathlib.a
[xxxxx:~] user% ranlib mymathlib.a
[xxxxx:~] user%
Then I drag/drop mymathlib.a (via the Finder) into my project folder. I
open the project and use "Add Files..." under the "Project" menu to add it
to the project, using the "default" reference style on that next sheet that
always pops up. When I look in the target of the project now, it has the
lib at the bottom of the "Frameworks and Libraries" list.
This is 10.2 with latest project builder. Using gcc3.
As you can see from the pico session above, i'm prototyping the adder()
function. I also tried adding a little function prototype at the top of the
obj-c header, but it made no difference either way.
Here's the obj-c code:
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
#import <Cocoa/Cocoa.h>
int adder(int a, int b);
@interface MyObject : NSObject { }
@end
@implementation MyObject
- (void)applicationDidFinishLaunching:(NSNotification *)notif {
printf("%d\n", (int)adder((int)4,(int)5));
}
@end
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
Thanks.
- Philip
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.