Ios xCode 4.3.2链接错误,但arch确实存在。为什么?

Ios xCode 4.3.2链接错误,但arch确实存在。为什么?,ios,xcode,compilation,linker,amr,Ios,Xcode,Compilation,Linker,Amr,我试图将AMR-NB解码支持添加到iOS应用程序中,这在以前已经成功完成。但是自从我升级了我使用的框架(PhoneGap,现在是Cordova),我开始了一个新项目,并将所有代码迁移到新的项目中,AMR-NB库在链接过程中开始出错 我一直在使用'file'和'lipo-info'命令检查.a lib文件,并确保fat lib包含i386的arch,并且它已经包含在构建短语中的链接短语中。我一直在比较新项目和旧项目的构建设置,但没有发现解决这个问题的运气 有人知道我哪里弄错了吗?谢谢 更新:添加

我试图将AMR-NB解码支持添加到iOS应用程序中,这在以前已经成功完成。但是自从我升级了我使用的框架(PhoneGap,现在是Cordova),我开始了一个新项目,并将所有代码迁移到新的项目中,AMR-NB库在链接过程中开始出错

我一直在使用'file'和'lipo-info'命令检查.a lib文件,并确保fat lib包含i386的arch,并且它已经包含在构建短语中的链接短语中。我一直在比较新项目和旧项目的构建设置,但没有发现解决这个问题的运气

有人知道我哪里弄错了吗?谢谢

更新:添加了amrFileCodec.h和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
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
//amrFileCodec.h
//唐小平于2011年9月27日创作。
//版权所有2011年测试。版权所有。
#ifndef amrFileCodec\u h
#定义amrFileCodec_h
#包括
#包括
#包括
#包括“国际12月h日”
#包括“内部附件”
...
// 将AMR文件解码成波动文件
int DecodeAMRFileToWAVEFile(常量字符*pchAMRFileName,常量字符*pchWAVEFilename);
#恩迪夫
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
//CJ Func.m
//伊比尔
//由Chris Jiang于11-4-22创建。
//版权所有2011个人。版权所有。
#导入“CJ Func.h”
#导入“国际12月h日”
#输入“国际编码”
#导入“amrFileCodec.h”
@实现MyPGPlugFunc
...
-(void)decodeAMR:(NSMutableArray*)参数和dict:(NSMutableDictionary*)选项{
NSArray*CurrentPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,是);
NSString*basePath=[currentPaths objectAtIndex:0];
NSString*wavDir=[basePath stringByAppendingPathComponent:@“tmp/wav”];
NSString*wavPath=[basePath stringByAppendingPathComponent:[arguments objectAtIndex:1]];
NSLog(@“[CJ-FUNC]解码%@到%@”,[arguments objectAtIndex:0],wavPath);
BOOL-isDir=是;
NSFileManager*fileMgr=[NSFileManager defaultManager];
if(![fileMgr fileExistsAtPath:wavDir isDirectory:&isDir]){
if(![fileMgr createDirectoryAtPath:wavDir with IntermediateDirectory:YES属性:nil错误:nil])
NSLog(@“[CJ-FUNC]错误:tmp/wav目录创建失败”);
其他的
NSLog(@“[CJ-FUNC]tmp/wav目录已创建”);
}
[fileMgr发布];
int encRes=DecodeAMRFileToWAVEFile(
[[arguments objectAtIndex:0]CStringUsingEncode:NSASCIIStringEncoding],
[wavPath cStringUsingEncoding:NSASCIIStringEncoding]
);
如果(encRes消息“未定义架构i386的符号”并不意味着您的库缺少i386架构。重要的部分是下一行:

“_DecodeAMRFileToWaveFile”,引用自CJ Func.o中的-[MyPGPlugFunc decodeAMR:withDict:]

<>听起来好像你有一个函数,在Debug -c++文件中定义,但是你想从.m文件中使用它。所以你要处理C编译函数与C++如何做的区别。你需要告诉C++使函数看起来像一个普通的C函数。 您需要在头文件中包含以下内容:

#ifdef __cplusplus
extern "C" {
#endif

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

#ifdef __cplusplus
}
#endif
这里有一个和一个。

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

“_DecodeAMRFileToWaveFile”,引用自CJ Func.o中的-[MyPGPlugFunc decodeAMR:withDict:]

<>听起来好像你有一个函数,在Debug -c++文件中定义,但是你想从.m文件中使用它。所以你要处理C编译函数与C++如何做的区别。你需要告诉C++使函数看起来像一个普通的C函数。 您需要在头文件中包含以下内容:

#ifdef __cplusplus
extern "C" {
#endif

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

#ifdef __cplusplus
}
#endif

这是一个,和一个。

我已经检查了一遍又一遍,没有发现解决这个问题的任何运气。函数DecodeAMRFileToWaveFile是用objective-c++编写的,我已经将它导入到CJ Func.m中了。不过,似乎.m文件无法识别头文件。这太奇怪了@@"Thx用于编辑,但我仍然不明白。正如我在主要问题上编辑的那样,函数名为“DecodeAMRFileToWaveFile”,没有“uu”,但链接器似乎在寻找“DecodeAMRFileToWaveFile”?为什么?CJ Func.m调用的部分是“int encRes=DecodeAMRFileToWaveFile…”参见指向其他问题的链接t我只是补充了一下。C总是为符号加上一个“符号”,因为古语和晦涩的原因。C++用不同的方式来对它们进行标记(一,它对参数类型进行编码,并返回值)。这是不兼容的。好吧,在添加extern def之后,链接器工作了。非常感谢您的帮助和好意。但是,我仍然不明白它为什么调用不同的函数名。是不是xCode将外部C/C++函数名称空间与其本机名称空间区分开来的方式?哈哈,刚刚在注释中发布最后一个问题后看到了答案。Tha又是nks!我一次又一次地检查了这个问题,但没有发现解决这个问题的任何运气。函数DecodeAMRFileToWaveFile是用objective-c++编写的,我已经将它导入到CJ Func.m中了。不过,.m文件似乎无法识别头。这太奇怪了@@"Thx用于编辑,但我仍然不明白。正如我在主要问题上编辑的那样,函数名为“DecodeAMRFileToWaveFile”,没有“uu”,但链接器似乎在寻找“DecodeAMRFileToWaveFile”?为什么?CJ Func.m调用的部分是“int encRes=DecodeAMRFileToWaveFile…”参见指向其他问题的链接t我只是添加了。C总是给符号加上“‘’”,因为古例和晦涩的原因。C++用不同的方法把它们(一个,它对参数类型和返回值进行编码)不兼容。