Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weak linking vs. non-weak Linking



I have a body of code built using Availability Macros and the MACOSX_DEPLOYMENT_TARGET environment variables that uses some Tiger features but needs to run on 10.3 (I'm using gestalt etc. to make sure I don't call the new features on the old OS).

The project is built using some code collected into a static library and then linking the static library against some 'loose' object files. Running nm -mg on one of the object files in the static library says :

nm -mg ZBitmap.o | grep CGL
         (undefined) weak external _CGLayerCreateWithContext
         (undefined) weak external _CGLayerGetContext

(I get the same result for using nm -mg on the static library)

Which looks just great. However when I run the same command against the finished bundle the weak reference has disappeared :

nm -mg /Volumes/Source/main/builds/macos/BIAS\ Sqweez-5.vst/Contents/ MacOS/BIAS\ Sqweez-5 | grep CGL
(undefined) external _CGLayerCreateWithContext (from Carbon)
(undefined) external _CGLayerGetContext (from Carbon)


The weak reference has 'disappeared' and been replaced by a 'strong' one. The only use of CGLayer is in the one object file (ZBitmap.o) none of the other files compiled in call any CGLayer functions. So somehow during my final link stage the reference is 'dropped'.

What could cause this ? I've tried a smaller example of linking my library against a simpler object file and of course it works. Yet my 'broken case' isn't that complicated. I link approx 10 objects against the library - I can't systematically reduce the broken case by removing object files from the link line one by one to see if any one is a culprit since they're interdependent.

Any thoughts or suggestions ?

Thanks

Andrew 8-)

P.S. I'm building with gcc 4.0/XCode 2.0

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.