1

AMR-NB デコード サポートを iOS アプリに追加しようとしていましたが、これは以前に成功しました。しかし、使用していたフレームワーク (PhoneGap、現在は Cordova) をアップグレードしてから、新しいプロジェクトを開始し、すべてのコードを新しいプロジェクトに移行したところ、フレーズのリンク中に AMR-NB lib でエラーが発生し始めました。

ここに画像の説明を入力

「file」および「lipo -info」コマンドを使用して .a lib ファイルをチェックしており、fat lib に i386 の arch が含まれていること、およびビルド フレーズのリンク フレーズに既に含まれていることを確認しました。新しいプロジェクトと古いプロジェクトのビルド設定を比較してきましたが、これを解決する運がありませんでした。

どこが間違っているのか誰か知っていますか?どうも!

更新: 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
4

1 に答える 1

1

「アーキテクチャ i386 のシンボルが未定義です」というメッセージは、ライブラリに i386 アーキテクチャがないという意味ではありません。重要な部分は次の行です。

CJ-Func.o の -[MyPGPlugFunc decodeAMR:withDict:] から参照される「_DecodeAMRFileToWaveFile」

Obj-C++ .mm ファイルで定義されている関数 DecodeAMRFileToWaveFile() があるようですが、.m ファイルから使用しようとしています。したがって、C が関数をコンパイルする方法と C++ がそれを行う方法の違いに直面しています。関数をプレーンな C 関数のように見せるように C++ に指示する必要があります。

ヘッダーファイルでこれが必要です:

#ifdef __cplusplus
extern "C" {
#endif

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

#ifdef __cplusplus
}
#endif

C++ FAQのリファレンスと、より詳細な説明があります。

于 2012-04-11T03:22:15.510 に答える