PDA

View Full Version : Qt + cocoa : Undefined symbols for architecture x86_64



karankumar1609
20th March 2013, 09:43
Hello Everyone,

I am combining cocoa code in Qt, unfortunately a symbol not found error occurred.
I am using MAC OSX 10.8.2 and Qt Creator to build my code.

appcontroller.h


#ifndef APPCONTROLLER_H
#define APPCONTROLLER_H

// Import the Cocoa and ImageCaptureCore headers
#include <Cocoa/Cocoa.h>
#include <ImageCaptureCore/ImageCaptureCore.h>

// Create a public interface for the controller
@interface appController : NSObject

// Create delegates for the device browser and camera device classes.
<ICDeviceBrowserDelegate, ICCameraDeviceDelegate> {

// Create an instance variable for the device browser
// and an array for the cameras the browser finds
ICDeviceBrowser * mDeviceBrowser;
NSMutableArray * mCameras;

// Define Interface Builder outlets for two
// array controllers -- one for cameras,
// one for the chosen camera's files
IBOutlet NSArrayController * mCamerasController;
IBOutlet NSArrayController * mMediaFilesController;

// Define IB outlets for the tableviews used to
// display the cameras and the chosen camera's contents
IBOutlet NSTableView * mCameraContentTableView;
IBOutlet NSTableView * mCamerasTableView;
}

// Cameras are properties of the device browser stored in an array
@property(retain) NSMutableArray* cameras;

// Create a boolean to indicate whether the camera has images to download
@property(readonly) BOOL canDownload;
@end


#endif // APPCONTROLLER_H




appcontroller.mm


#include "appcontroller.h"

// The camera device returns core graphics image refs,
// convert them to NSImages for table view
@interface NSImageFromCGImageRef: NSValueTransformer {}
@end
@implementation NSImageFromCGImageRef
+ (Class)transformedValueClass { return [NSImage class]; }
+ (BOOL)allowsReverseTransformation { return NO; }
- (id)transformedValue:(id)item
{
if ( item )
return [[[NSImage alloc] initWithCGImage:(CGImageRef)item size:NSZeroSize] autorelease];
else
return nil;
} @end
@implementation appController

// synthesize the getters and setters for camera properties
@synthesize cameras = mCameras;

// Main task -- on launch
- (void)applicationDidFinishLaunching:(NSNotificatio n*)notification
{
mCameras = [[NSMutableArray alloc] initWithCapacity:0];

// Get an instance of ICDeviceBrowser
mDeviceBrowser = [[ICDeviceBrowser alloc] init];
// Assign a delegate
mDeviceBrowser.delegate = self;
// Look for cameras in all available locations
mDeviceBrowser.browsedDeviceTypeMask = mDeviceBrowser.browsedDeviceTypeMask
| ICDeviceTypeMaskCamera
| ICDeviceLocationTypeMaskLocal
| ICDeviceLocationTypeMaskShared
| ICDeviceLocationTypeMaskBonjour
| ICDeviceLocationTypeMaskBluetooth
| ICDeviceLocationTypeMaskRemote;
// Start browsing for cameras
[mDeviceBrowser start];

}

// Stop browser and release it when done
- (void)applicationWillTerminate:(NSNotification*)no tification {
mDeviceBrowser.delegate = NULL;
[mDeviceBrowser stop];
[mDeviceBrowser release];
[mCameras release];
}

// Method delegates for device added and removed
//
// Device browser maintains list of cameras as key-value pairs, so delegate
// must call willChangeValueForKey to modify list
- (void)deviceBrowser:(ICDeviceBrowser*)browser didAddDevice:(ICDevice*)addedDevice moreComing:(BOOL)moreComing
{
if ( addedDevice.type & ICDeviceTypeCamera )
{
addedDevice.delegate = self;

// implement manual observer notification for the cameras property
[self willChangeValueForKey:@"cameras"];
[mCameras addObject:addedDevice];
[self didChangeValueForKey:@"cameras"];
}
}


- (void)deviceBrowser:(ICDeviceBrowser*)browser didRemoveDevice:(ICDevice*)device moreGoing:(BOOL)moreGoing
{
device.delegate = NULL;

// implement manual observer notification for the cameras property
[self willChangeValueForKey:@"cameras"];
[mCameras removeObject:device];
[self didChangeValueForKey:@"cameras"];
}

- (void)didRemoveDevice:(ICDevice*)removedDevice
{
[mCamerasController removeObject:removedDevice];
}

// Check to see if the camera has image files to download
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
{
if ( [keyPath isEqualToString:@"selectedObjects"] && (object == mMediaFilesController) )
{
[self willChangeValueForKey:@"canDownload"];
[self didChangeValueForKey:@"canDownload"];
}
}

- (BOOL)canDownload
{
if ( [[mMediaFilesController selectedObjects] count] )
return YES;
else
return NO;
}

// Download images
// (Add a download button in interface builder -- use boolean to enable button)
- (void)downloadFiles:(NSArray*)files
{
NSDictionary* options = [NSDictionary dictionaryWithObject:[NSURL fileURLWithPath:[@"~/Pictures" stringByExpandingTildeInPath]] forKey:ICDownloadsDirectoryURL];

for ( ICCameraFile* f in files )
{
[f.device requestDownloadFile:f options:options downloadDelegate:self didDownloadSelector:@selector(didDownloadFile:erro r:options:contextInfo:) contextInfo:NULL];
}
}

// Done downloading -- log results to console for debugging
- (void)didDownloadFile:(ICCameraFile*)file error:(NSError*)error options:(NSDictionary*)options contextInfo:(void*)contextInfo
{
NSLog( @"didDownloadFile called with:\n" );
NSLog( @" file: %@\n", file );
NSLog( @" error: %@\n", error );
NSLog( @" options: %@\n", options );
NSLog( @" contextInfo: %p\n", contextInfo );
}
@end



and
ObjectiveC-Integrate.pro


QT += core gui multimedia

TARGET = ObjectiveC-Integrate
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

CONFIG -= app_bundle
CONFIG += x86_64
CONFIG -= i386
LIBS += -lssl -lcrypto
LIBS += -framework AppKit

OBJECTIVE_HEADERS += \
appcontroller.h

OBJECTIVE_SOURCES += \
appcontroller.mm

after a lot of search on google and review other posts i am unable to make my code BUILD on my machine.
Please help me out of this problem.