• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Solved: "C" Functions Won't Link Between .mm Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Solved: "C" Functions Won't Link Between .mm Files


  • Subject: Re: Solved: "C" Functions Won't Link Between .mm Files
  • From: Chris Espinosa <email@hidden>
  • Date: Tue, 13 Dec 2005 21:37:20 -0800

On Dec 13, 2005, at 9:21 PM, Jerry Krinock wrote:

If I linked my Cocoa application with Build Configuration "Debug", it linked
with no errors but upon running the app quit immediately with this console
message:


ZeroLink: unknown symbol
'__Z48ParseArrayOfCommandLineArgumentsForLetterCommandP7NSArrayP8NSStri ng'


If instead I linked it with Build Configuration "Deployment", I got a bunch
of "Undefined symbol" errors during linking. It looked like I got an error
for each plain-old C function such as "void MyFunction(int someArg)" which
was called in one file but defined in another file.


I discovered hat the problem was only occurring if one of the files had the
.mm extension instead of .m. (This project was born as Objective-C++).
Removing .mm files, changing all .mm extentions to .m, and re-adding the
files fixed the problem.


Is this a bug, a feature, or another CodeWarrior exit exam which I have
failed?  (It links fine with the .mm extensions in CodeWarrior.)

Two things are at work here. First, while CodeWarrior pretty much always compiles everything as C++, Xcode and gcc take your word for it and build .c files with plain C instead of C++. That means that external references can't be name-mangled as they are in C++. Changing your .mm files to .m changed them from Objective-C++ to Objective-C which uses the same symbol space as straight C.


The second thing is that by default, your Debug configurations build with the ZeroLink feature, which defers link errors to runtime for faster turnaround once your project is building correctly. Building Release shows you the link errors which ZeroLink [by dint of not actually linking] hid. Safety tip: always try a Release build, or turn off ZeroLink in the Build menu.

Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Solved: "C" Functions Won't Link Between .mm Files (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Solved: "C" Functions Won't Link Between .mm Files
  • Next by Date: Re: Solved: "C" Functions Won't Link Between .mm Files
  • Previous by thread: Solved: "C" Functions Won't Link Between .mm Files
  • Next by thread: Re: Solved: "C" Functions Won't Link Between .mm Files
  • Index(es):
    • Date
    • Thread