2012-04-11 10 views
1

AMR-NBデコードのサポートをiOSアプリケーションに追加しようとしていましたが、これは以前に成功しました。しかし、私が使用したフレームワーク(PhoneGap、現在はCordova)をアップグレードしてから、新しいプロジェクトを開始し、すべてのコードを新しいものに移行すると、AMR-NB libはリンクする際にエラーを起こします。xCode 4.3.2リンクエラーですが、アーチには存在しません。どうして?

enter image description here

私は「ファイル」と「リポ-info」コマンドでは.aの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日以来探しています。あなたのコードで最後に成功しました。ありがとう。ハッピーコーディング。 –

答えて

1

追加されましたメッセージ "アーキテクチャi386の未定義シンボル"は、ライブラリにi386アーキテクチャがないことを意味しません。

"_DecodeAMRFileToWaveFile"、から参照:重要な部分は、次の行である - [MyPGPlugFunc decodeAMR:withDict:]あなたが機能DecodeAMRFileToWaveFileを持っているよう

CJ-Func.oにですね()これは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++ FAQ、およびmore detailed explanationです。

+0

私はこれを何度も確認しており、これを解決する運を見つけられませんでした。関数DecodeAMRFileToWaveFileはobjective-C++で書かれていますが、これをCJ-Func.mに#importしました。それでも、ヘッダーが.mファイルによって認識されないようです。それはとても奇妙です。 @@ " – JiangCat

+0

これはキーです編集済みの回答を参照 –

+0

編集のThxですが、これはまだ得られません主な質問を編集したので、この関数の名前は 'DecodeAMRFileToWaveFile' CJ-Func.mが呼び出す部分は 'int encRes = DecodeAMRFileToWAVEFile ...'でした。 – JiangCat

関連する問題