2013-03-26 48 views
0

我將Qt中的可可代碼合併在一起,但不幸發現符號未找到錯誤。 我使用MAC OSX 10.8.2和Qt Creator來構建我的代碼。Qt + cocoa:架構x86_64的未定義符號

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:(NSNotification*)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*)notification { 
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:error: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 

要複製到剪貼板,很多在谷歌搜索後,切換以純文本模式 並查看其他職位,我不能讓我的機器上我的代碼生成。 當我在main.cpp中包含上面的COCOA頭文件時,成千上萬的錯誤出現(@ stray)。

回答

相關問題