"Undefined symbols for architecture x86_64" link-time error with FFTW

Hi Jucers,

I’m having an issue building my plugin with the FFTW library. I’m running Xcode 11.4.1 on Catalina 10.15.4. Below is the full error message:

Error:
Undefined symbols for architecture x86_64: "_fftw_alloc_complex", referenced from: PlaygroundAudioProcessor::initFFT(int) in libPlayground.a(PluginProcessor.o) "_fftw_destroy_plan", referenced from: PlaygroundAudioProcessor::deinitFFT() in libPlayground.a(PluginProcessor.o) "_fftw_execute", referenced from: PlaygroundAudioProcessor::processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) in libPlayground.a(PluginProcessor.o) "_fftw_free", referenced from: PlaygroundAudioProcessor::deinitFFT() in libPlayground.a(PluginProcessor.o) "_fftw_plan_dft_1d", referenced from: PlaygroundAudioProcessor::initFFT(int) in libPlayground.a(PluginProcessor.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

In ‘Header Search Paths’ in the Projucer I put the path to the fftw-3.3.8 main directory, and included the fftw3.h file in my audio processor editor header like so:

#include <api/fftw3.h>

As per advice I have found, I dropped the fftw3.h and static library libfftw3.a and libfftw3f.a files (I believe these are for the standard library and floating point precision libraries respectively) into the source folder in the Projucer. I have checked the architecture type in my build settings and the only options are the defaulted ‘Standard Architectures (64-bit Intel)’, ‘Native Architecture of Build Machine’ or ‘64-bit Intel’ - none of which build.

I feel the issue could be down to a 32/64-bit compatibility discrepancy but I’m also new to Juce and C++, so I’m not particularly confident in my library linking technique either! Any advice would be greatly appreciated!

This won’t work. libfftw3.a and libfftw3f.a are not source files to compile. They are external libraries that you can link. You should add libfftw3 and libfftw3f to the “External Libraries to Link” field of the “Xcode (MacOSX)” exporter and set the “Extra Library Search Paths” of each configuration to the folder that contains them.

I hope this helps!

1 Like

Thank you so much @McMartin!

That has gotten rid of all the error messages apart from one:

ld: library not found for -l/usr/local/Cellar/fftw/3.3.8_1/lib/libfftw3.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas?

You can try adding the .a files in your Xcode project: in the project navigator on your left click the project that contains all your files, then go to Build Phases. There you should be able to add your libraries to link. The downside of this is that everytime you open your project with Projucer you’ll have to add them again, but not if you open your project from .xcodeproj in your build folder.

Hi @johngalt91, thank you for this!

Do you mean add the library to each ‘Link Library with Binary’ in all the targets in Build Phases? If so, I have tried this and unfortunately no luck.