Apple Mach-O链接器错误:架构armv7的未定义符号

时间:2014-11-27 14:04:28

标签: ios linker-errors

虽然这里已经有很多类似的问题,但我仍然无法解决这个问题。

我正在开发一些IOS应用程序,大部分文件都是由Object-C编写的。但 我需要使用一些关于FFT的算法,所以我创建了一个C文件(包括头文件)来计算 它。当我尝试将其编译成IOS设备时,我得到了Apple Mach-O链接器错误。

因为我可以发布任何图像,所以我在这里复制日志。 对于那个很抱歉。 好像那样:

     Ld /Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Products/Debug-iphoneos/Decode.app/Decode normal armv7
            cd /Users/nekonosukiyaki/Mr.WORK/MyProjects/IOS/Decode
            export IPHONEOS_DEPLOYMENT_TARGET=8.1
            export PATH="
                        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"       
                        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 -isysroot 
                        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Products/Debug-iphoneos -F/Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Products/Debug-iphoneos -filelist /Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Intermediates/Decode.build/Debug-iphoneos/Decode.build/Objects-normal/armv7/Decode.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -stdlib=libc++ -fobjc-link-runtime -miphoneos-version-min=8.1 -Xlinker -dependency_info -Xlinker /Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Intermediates/Decode.build/Debug-iphoneos/Decode.build/Objects-normal/armv7/Decode_dependency_info.dat -o /Users/nekonosukiyaki/Library/Developer/Xcode/DerivedData/Decode-eqksrmyvutoiidgpubzmnxbofxmr/Build/Products/Debug-iphoneos/Decode.app/Decode

        Undefined symbols for architecture armv7:
          "rdft(int, int, double*, int*, double*)", referenced from:
              ___31-[ViewController pushStartBTN:]_block_invoke in ViewController.o
        ld: symbol(s) not found for architecture armv7
        clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不擅长英语,但我会尽力让你知道我的问题。 再次,非常感谢。

(a)在我的.h文件中:

void cdft(int n, int isgn, double *a, int *ip, double *w);
void rdft(int n, int isgn, double *a, int *ip, double *w);
void ddct(int n, int isgn, double *a, int *ip, double *w);
void ddst(int n, int isgn, double *a, int *ip, double *w);
void dfct(int n, double *a, double *t, int *ip, double *w);
void dfst(int n, double *a, double *t, int *ip, double *w);

(b)在.c文件中

void rdft(int n, int isgn, double *a, int *ip, double *w)
{
    void makewt(int nw, int *ip, double *w);
    void makect(int nc, int *ip, double *c);
...

(c)在.m文件中

- (IBAction)pushStartBTN:(UIButton *)sender {
    Novocaine *audioManager = [Novocaine audioManager];
    self.audioManager = audioManager;
    [self.audioManager setInputBlock:^(float *newAudio, UInt32 numSamples, UInt32 numChannels) {
        // Now you're getting audio from the microphone every 20 milliseconds or so. How's that for easy?
        // Audio comes in interleaved, so,
        // if numChannels = 2, newAudio[0] is channel 1, newAudio[1] is channel 2, newAudio[2] is channel 1, etc.

//        NSLog(@"newAudio: %f, numSamples: %u, numChannnels: %u",*newAudio,(unsigned int)numSamples,(unsigned int)numChannels);
        double data[numSamples * 2];
        int *ip = (int *)malloc(sizeof(int) * (2 + sqrt((double)(numSamples*2))));
        double *w = (double *)malloc(sizeof(double) * (numSamples));
        ip[0] = 0;
        double *spectrum = (double *)malloc(sizeof(double)*512);

        if (numChannels == 2) {
            NSLog(@"2 channels and quit");
        }
        else {
            for (int i=0; i<numSamples; i++) {
                data[i<<1] = newAudio[i] * _window.win[i];
                data[(i<<1)+1] = 0;
            }
            rdft(numSamples*2, 1, (double *)data, ip, w);
        }
        for (int i=400; i<470; i++) {
            spectrum[i] = 10*log10(pow(data[i<<1], 2)+pow(data[(i<<1)+1], 2));
        }
        Threshold *threshold = [[Threshold alloc]initWithTrig:spectrum[450] :spectrum[454] :0.9];
        [threshold calThresByIREF];
        NSLog(@"threshold: %f",threshold.threshold);
    }];
    [self.audioManager play];
}

(d)我不能编译.c但是.c文件中的函数是由.c编写的 如果我只是在C程序中使用它,它可以很好地运作。

由于代码很长,以至于我无法将其全部复制到此处。我很抱歉。非常感谢你。

0 个答案:

没有答案