[英]Canon EDSDK crashes with EXC_BAD_ACCESS on Mac OS 10.7.5 on a very basic program
I am trying to write a console based application to access a Canon camera on Mac OS X 10.7.5. 我试图编写一个基于控制台的应用程序来访问Mac OS X 10.7.5上的佳能相机。 I am using XCode version 4.6 for the same.
我使用的是XCode 4.6版。 This is the program I am trying to write
这是我正在尝试编写的程序
#import <Foundation/Foundation.h>
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
int main()
{
@autoreleasepool {
EdsError error = EDS_ERR_OK;
EdsCameraListRef cameraList = NULL;
EdsUInt32 count = 0;
EdsDeviceInfo deviceInfo;
bool isSDKLoaded;
// Initialization of SDK
error = EdsInitializeSDK();
//Acquisition of camera list
if(error == EDS_ERR_OK)
{
isSDKLoaded = YES;
error = EdsGetCameraList(&cameraList);
}
if(cameraList != NULL) {
EdsRelease(cameraList);
cameraList = NULL;
}
}
return 0;
}
It compiles successfully but when I run the program it crashes when the EdsGetCameraList function returns. 它可以成功编译,但是当我运行程序时,当EdsGetCameraList函数返回时,它会崩溃。 The error shown is 'dyld misaligned_stack_error'.
显示的错误是“ dyld misaligned_stack_error”。 I understand that this has something to do with the fact that MacOS X wants the stack to be 16-byte aligned.
我知道这与MacOS X希望堆栈以16字节对齐的事实有关。 The SDK I am using is only available for 32 bit architectures and hence, I have set the architecture accordingly.
我使用的SDK仅适用于32位体系结构,因此,我已相应地设置了体系结构。 I tried setting the "Other C flags" under Build Settings in XCode to include the flag "-falign-stack=assume-16-byte" as well.
我尝试在XCode的“构建设置”下设置“其他C标志”,使其也包含标志“ -falign-stack = assume-16-byte”。
The sample that came along with the Canon EDSDK works fine. 佳能EDSDK随附的示例工作正常。 The version of the SDK being used is the one developed by Canon in 2006-2007 updated on 06-03-16.
使用的SDK版本是佳能在2006-2007年开发的版本,更新于06-03-16。 I have no other version information on it.
我没有其他版本信息。
Following is the dump from the logs : http://pastebin.com/vfDWeZnr 以下是日志中的转储: http : //pastebin.com/vfDWeZnr
What could I be possibly doing wrong? 我可能做错了什么?
I am really new to Objective-C and hence, the mix up of C and Objective-C code. 我对Objective-C真的很陌生,因此,我将C和Objective-C代码混在一起。
Thanks! 谢谢!
Are you sure that you don't need to initialize cameraList
? 您确定不需要初始化
cameraList
吗? I imagine that the function wants to write to the address you supply but that points to NULL
, hence the error. 我想像该函数想要写入您提供的地址,但是它指向
NULL
,因此出错。 In C I'd use malloc()
here to obtain a pointer but I don't know the equivalent for objective-C. 在C语言中,我将在这里使用
malloc()
获得一个指针,但我不知道Objective-C的等效语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.