2012-04-11 37 views
1

我正试图将AMR-NB解码支持添加到之前已成功完成的iOS应用中。但是,由于我升级了我使用的框架(PhoneGap,现在称为Cordova),我开始了一个新项目并将所有代码迁移到新项目,AMR-NB lib在链接短语期间开始出错。xCode 4.3.2链接错误,但是确实存在。为什么?

enter image description here

我已经检查与“文件”和“脂-info”命令。一个LIB文件,并确保脂肪LIB包含了i386的弓,而且它已经包括在连接词组在构建短语。我一直在比较新旧项目的构建设置,但发现没有运气来解决这个问题。

有谁知道我可能弄错了吗?谢谢!

更新:添加的amrFileCodec.h和CJ-Func.m的代码片段

的amrFileCodec.h

// amrFileCodec.h 
// Created by Tang Xiaoping on 9/27/11. 
// Copyright 2011 test. All rights reserved. 

#ifndef amrFileCodec_h 
#define amrFileCodec_h 
#include <stdlib.h> 
#include <string.h> 
#include <stdio.h> 
#include "interf_dec.h" 
#include "interf_enc.h" 

... 

// 将AMR文件解码成WAVE文件 
int DecodeAMRFileToWAVEFile(const char* pchAMRFileName, const char* pchWAVEFilename); 

#endif 

的CJ-Func.m

// CJ-Func.m 
// iBear 
// Created by Chris Jiang on 11-4-22. 
// Copyright 2011 Individual. All rights reserved. 

#import "CJ-Func.h" 
#import "interf_dec.h" 
#import "interf_enc.h" 
#import "amrFileCodec.h" 

@implementation MyPGPlugFunc 

... 

- (void)decodeAMR:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options { 
    NSArray *currentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *basePath = [currentPaths objectAtIndex:0]; 
    NSString *wavDir = [basePath stringByAppendingPathComponent:@"tmp/wav"]; 
    NSString *wavPath = [basePath stringByAppendingPathComponent:[arguments objectAtIndex:1]]; 

    NSLog(@"[CJ-FUNC] Decoding %@ to %@", [arguments objectAtIndex:0], wavPath); 

    BOOL isDir = YES; 
    NSFileManager *fileMgr = [NSFileManager defaultManager]; 
    if (![fileMgr fileExistsAtPath:wavDir isDirectory:&isDir]) { 
     if (![fileMgr createDirectoryAtPath:wavDir withIntermediateDirectories:YES attributes:nil error:nil]) 
      NSLog(@"[CJ-FUNC] ERROR: tmp/wav directory creation failed"); 
     else 
      NSLog(@"[CJ-FUNC] tmp/wav directory created"); 
    } 
    [fileMgr release]; 

    int encRes = DecodeAMRFileToWAVEFile(
     [[arguments objectAtIndex:0] cStringUsingEncoding:NSASCIIStringEncoding], 
     [wavPath cStringUsingEncoding:NSASCIIStringEncoding] 
    ); 

    if (encRes <= 0) 
     [self writeJavascript:[NSString stringWithFormat:@"%@();", [arguments objectAtIndex:3]]]; 
    else 
     [self writeJavascript:[NSString stringWithFormat:@"%@('%@');", [arguments objectAtIndex:2], wavPath]]; 
} 

@end 
+0

自5天以来,我一直在寻找这种类型的实现。最终成功地与您的代码。谢谢你...快乐编码。 – 2018-01-23 20:20:55

回答

1

的消息“架构i386的未定义符号”并不意味着您的库缺少i386架构。最重要的部分是下一行:

“_DecodeAMRFileToWaveFile”,从引用 - [MyPGPlugFunc decodeAMR:withDict:在CJ-Func.o

这听起来像你有一个函数DecodeAMRFileToWaveFile() ,它是在一个Obj-C++ .mm文件中定义的,但是你想从.m文件中使用它。所以你会遇到C编译函数的方式与C++如何执行的区别。你需要告诉C++使这个函数看起来像一个普通的C函数。

你需要这个在你的头文件:

#ifdef __cplusplus 
extern "C" { 
#endif 

void DecodeAMRFileToWaveFile(); // or whatever its declaration is 

#ifdef __cplusplus 
} 
#endif 

这里有一个reference in the C++ FAQmore detailed explanation

+0

我一直在一次又一次地检查,并没有找到任何解决这个问题的运气。 DecodeAMRFileToWaveFile函数是用Objective-C++编写的,我已经将它导入到CJ-Func.m中。尽管如此,头文件似乎无法被.m文件识别。这太奇怪了。 @@“ – JiangCat 2012-04-11 03:29:52

+0

这是关键,编辑请参阅编辑答案 – 2012-04-11 03:35:48

+0

Thx,但我仍然没有得到这个,因为我在主要问题上编辑过,函数被命名为'DecodeAMRFileToWaveFile',而'_' ,但似乎链接器正在寻找'_DecodeAMRFileToWaveFile'?为什么?CJ-Func.m调用的部分是'int encRes = DecodeAMRFileToWAVEFile ...' – JiangCat 2012-04-11 03:40:29

相关问题