Mailing Lists: Apple Mailing Lists

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

linker warnings: multiple definitions libSystem.dylib vs libmx.dylib: Solved -- but ?!?!



I am trying to build a project that built fine under previous versions of XCode (yada, yada) but now I get a collection of linker multiple-definition warnings for math functions. Rather than fight it in the original project which is rather large and complex, I have a test project that duplicates the problem by simply linking in the Cocoa and Accelerate frameworks and making a single call to sqrtf().

It appears (based on fooling around with the -whyload flag) that libSystem and libmx both contain definitions of numerous math functions, but unfortunately when _I_ invoke sqrtf, libmx is loaded, and when the Accelerate framework references some arbitrary math function, the math module of libSystem is loaded, generating the duplicate symbol warnings.

On a hunch, I tried adding an explicit reference to libSystem.dylib, both by using the "add to project" method and by using "-lSystem" in the target's Other Linker Flags (but not both at once). In both cases, all of the duplicate symbol message magically vanished.

So why are you reading this?

While this problem is thus sort-of solved, I am not particularly satisfied with the solution. The core problem appears to be that libmx gets searched before libSystem does, simply because it alpha- sorts first. This would appear to be an undesirable behavior, prone to wasting hours of developer-time. It would seem to me that there should be an implicit -lSystem in any Cocoa application project, since even an empty Cocoa app project makes a bajillion references to libSystem.dylib.

But there also should be some sort of mechanism in XCode to detect and manage this kind of issue.

Yeah, I'm going to submit this as a bug, but I thought this might help someone out there.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/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.