Apple Mach-O Linker error: Undefined symbols for armv7 architecture
Although there are already many similar questions here, I still can't seem to resolve this issue.
I am developing an IOS application and most of the file is written by Object-C. But I need to use some algorithm about FFT, so I created a C file (including the head file) to calculate This. When I tried to compile it in IOS Device I got Apple Mach-O Linker error.
Because I can post any image, so I copy the log here. Sorry about that. it looks like this:
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)
I am not good at English, but I try to do my best to let you know about my problem. Thanks again.
(a) in my .h file:
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) in .c file
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) in .m file
- (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 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) I cannot compile .c, but the function in the .c file was written by a professor and it can work well if I only use it in a C program.
since the code is so long that I cannot copy it here. I am so sorry. Thank you very much.
source to share
No one has answered this question yet
Check out similar questions: