来自可可的exiftool

时间:2018-10-02 23:44:17

标签: cocoa exiftool

我正在尝试使用exiftool可可形式

#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;
}

1 个答案:

答案 0 :(得分:0)

事实证明,与此相关的C ++代码文件已复制到应用程序中,而不是被编译。它按预期工作。仅有头文件就没有错误,而且相当隐秘。