Linking Errors

Discussion in 'Mac Programming' started by nujjus, Apr 13, 2008.

  1. macrumors newbie

    Joined:
    Apr 12, 2008
    #1
    Hi!

    I was wondering if anyone might know why I get the following linking errors when I try to compile and run the Apple CoreLocation sample code:


    "_kCLLocationAccuracyKilometer", referenced from:
    _kCLLocationAccuracyKilmoeter$non_lazy_ptr in MyLocationGetter.o


    and

    ".objc_class_name_CLLocationManager", referened from:
    literal-pointer@__OBJC@__cls_refs@CLLocationManager in MyLocationGetter.o
    symbol(s) not found
    collect2: ld returned 1 exit status



    In my header file, I've imported <CoreLocation/CoreLocation.h> and I've declared locationManager as a class property. The class extends NSObject and conforms to CLLocationManagerDelegate.



    My .m file looks like this:
    Code:
    #import "MyLocationGetter.h"
    
    @implementation MyLocationGetter 
    
    @synthesize locationManager;
    
    - (void)startUpdates 
    { 
    	// Create the location manager if this object does not 
    	// already have one. 
    	if (nil == locationManager) 
    		locationManager = [[CLLocationManager alloc] init];		//it appears to have beef with CLLocationManager
    	locationManager.delegate = self; 
    	locationManager.distanceFilter = 1000; // 1 kilometer 
    	locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;		//it appears to have beef with kCLLocationaccuracyKilometer
    	[locationManager startUpdatingLocation]; 
    } 
    
    Any help is appreciated, thanks!
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Have you included the relevant frameworks in your project?
     
  3. thread starter macrumors newbie

    Joined:
    Apr 12, 2008
    #3
    I thought so..

    my header file has both:

    #import <UIKit/UIKit.h>
    #import <CoreLocation/CoreLocation.h>


    Looking into the framework, CoreLocation has:

    Code:
    #ifndef __CORELOCATION__
    #define __CORELOCATION__
    
    #import <CoreLocation/CLLocation.h>
    #import <CoreLocation/CLLocationManager.h>
    #import <CoreLocation/CLLocationManagerDelegate.h>
    
    #endif /* __CORELOCATION__ */
    which includes what I need.
     
  4. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    No you actually need to add the framework to your project. Just including the header files is not enough.
     
  5. thread starter macrumors newbie

    Joined:
    Apr 12, 2008
    #5
    Thank you SO much!!
     

Share This Page