$non_lazy_ptr link error with agvtool version variables?
Asked Answered
P

1

8

I've been using agvtool for one of my iPhone apps on general principle, and have recently found a reason why I want to be able to check the version variable (so that I can re-copy help content into the Documents directory, if it's out of date). The variable, MyAppVersionNumber, defined in MyApp_vers.c, is auto-generated during the build. It gets generated in a .o file, and shows up in (the previous version?) of the linked app itself. So far so good, it would seem.

So now I've declared an extern double MyAppVersionNumber in the .m file where I need to use this (and later try to use it, just in an NSLog statement to get started), and I try to build for the iPhone simulator, and get a link error:

  "_MyAppVersionNumber", referenced from:
      _MyAppVersionNumber$non_lazy_ptr in HelpViewController.o
     (maybe you meant: _MyAppVersionNumber$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

So, what do I need to do differently, to get this to link?

I googled for $non_lazy_ptr and agvtool, and got nothing at all, and for just $non_lazy_ptr, which gave some things, but mostly applying to libraries, which this isn't, really (is it?). And in my diggings so far, I've yet to turn up a page about agvtool that actually talks in any detail about using the variables -- the ones I've read just casually say to declare an extern variable, which I've done.

Anyone familiar with this, and/or otherwise able to provide any help?

Thanks!

Polydeuces answered 31/7, 2010 at 2:30 Comment(4)
Hmmm... been doing more googling, and trying different things, and I found this: If I put the extern statement and the reference both into main.m, it works fine. Using it in my view controller class, though, fails to work... Is there some problem with having an extern variable accessible through a class (as defined by @interface and @implementation)? I've tried putting it inside @interface, which fails with error: expected specifier-qualifier-list before 'extern', and in various other places in my .h and .m (again $non_lazy_ptr link error). How do I get access via my class?Polydeuces
Note: I've found a way to solve my original problem (involving making sure my Help viewer views the latest content): Don't copy it to Documents (it's read-only, so not required). Still, it'd be nice to know what was going on, in case I ever want this variable for other reasons.Polydeuces
Sorry I could not understand ur question, deleted the answer.Plasma
Heh, no worries. Thanks for reporting back. :)Polydeuces
D
1

Since agvtool updates your plist's CFBundleVersion value, I suggest accessing the version number at run-time with:

NSDictionary *mainDictionary = [[NSBundle mainBundle] infoDictionary];
double myVersionNumber = [(NSString *)[infoDictionary objectForKey:@"CFBundleVersion"] doubleValue];
Diverting answered 15/3, 2011 at 6:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.