我正在尝试使用exiftool form Cocoa
#include <iostream>
#include "ExifTool.h" // this is a .mm file so that we can include C++ code/structures
@implementation MyClass
-(id)myInit
{
if (self = [super init])
{
ExifTool* tool = new ExifTool("/Users/trygve/Tools/exiftool");
}
}这显然只是一个测试,但在“新的ExifTool”行中,我遇到了崩溃:
dyld`dyld_fatal_error:
0x7fff5fc01074 <+0>: int3
-> 0x7fff5fc01075 <+1>: nop
Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
dyld: Symbol not found: __ZN8ExifToolC1EPKcS1_下面的代码在一个直接的C++终端程序中运行良好。这来自exiftool开发人员页面上的示例。为什么这段代码可以很好地工作,但当我尝试从Cocoa .mm文件中使用它时,它却不行?
#include <iostream>
#include "ExifTool.h"
int main(int argc, char **argv)
{
if (argc < 2) {
std::cout << "Example1: Read metadata from an image." << std::endl;
std::cout << "Please specify input file name" << std::endl;
return 1;
}
// create our ExifTool object
ExifTool *et = new ExifTool("/Users/trygve/Tools/exiftool");
// read metadata from the image
TagInfo *info = et->ImageInfo(argv[1],NULL,5);
if (info) {
// print returned information
for (TagInfo *i=info; i; i=i->next) {
std::cout << i->name << " = " << i->value << std::endl;
}
// we are responsible for deleting the information when done
delete info;
} else if (et->LastComplete() <= 0) {
std::cerr << "Error executing exiftool!" << std::endl;
}
// print exiftool stderr messages
char *err = et->GetError();
if (err) std::cerr << err;
delete et; // delete our ExifTool object
return 0;
}发布于 2018-10-03 18:45:09
事实证明,与此相关的C++代码文件被复制到应用程序中,而不是编译。它的工作方式与预期一致。只有头文件,没有错误,并且发生了相当隐秘的崩溃。
https://stackoverflow.com/questions/52617857
复制相似问题