globals: non_lazy_ptr error

I needed a way to have globals in my project. For example a time global that all functions and objects can see. I looked at ofMSAfluid example and saw the use of:

extern testApp *myApp;  

My class called Blade then accesses time like this:


BUT, the compiler chokes on the code and gives:

  "_myApp", referenced from:  
      _myApp$non_lazy_ptr in Blade.o  
     (maybe you meant: _myApp$non_lazy_ptr)  
ld: symbol(s) not found  

It’s a bit strange but I think I got it to work (once), but can’t remember what I did - at least I didn’t understand what I was doing. ld is creating some fake symbols as placeholders to deal with compilation order or something?

Using xcode 3.2.2 on macos os 10.6 with OF 61.


It was logical, again following Memo’s fluid example. I had to define an instance of testApp in main.cpp:

testApp *myApp;  
int main( ){  
  ofAppGlutWindow window;  
  ofSetupOpenGL(&window, 1024,768, OF_WINDOW);  
  myApp = new testApp;  

Once this was done the:

extern testApp *myApp;  

in testApp.h worked as the object was now defined.