PDA

View Full Version : Linking Errors




nujjus
Apr 13, 2008, 03:41 PM
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:

#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!



Cromulent
Apr 13, 2008, 03:49 PM
Have you included the relevant frameworks in your project?

nujjus
Apr 13, 2008, 04:03 PM
I thought so..

my header file has both:

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


Looking into the framework, CoreLocation has:

#ifndef __CORELOCATION__
#define __CORELOCATION__

#import <CoreLocation/CLLocation.h>
#import <CoreLocation/CLLocationManager.h>
#import <CoreLocation/CLLocationManagerDelegate.h>

#endif /* __CORELOCATION__ */

which includes what I need.

Cromulent
Apr 13, 2008, 04:10 PM
No you actually need to add the framework to your project. Just including the header files is not enough.

nujjus
Apr 13, 2008, 04:29 PM
Thank you SO much!!