28
votes

I'm using a powerbook (osx 10.5) and recently downloaded and installed FFTW 3.2 (link text). I've been able to compile and run some simple programs based on the online tutorial using the terminal:

g++ main.cpp -lfftw3 -lm

However, I can't get the same program to compile in Xcode. I get a linking error, "symbol(s) not found". There is a file called libfftw3.a in /usr/local/lib. How can this be linked? Furthermore, apparently the libraries have to be linked in a particular order, i.e. see: link text

thanks for any help

4

4 Answers

44
votes

To link to a .a library like this in Xcode you need to:

  • Double-click on your target or application in Xcode to open the Info window

  • Switch to the "Build" tab

  • Add -lfftw3 to "Other Linker Flags" (under "Linking")

  • Add the path to your library to the "Library Search Paths" (under "Search Paths"). In your case this will be /usr/local/lib

We use FFTW (it's great by the way), this works for us!

8
votes

Did you set these options for the target?

Under "Linking->Other Linker Flags" add: "-L/path/to/library -lfftw3 -lm"

1
votes

warning in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libfftw3.a, file is not of required architecture

Maybe the binary format was different e.g. the library could be 32 bit while the application 64.

-2
votes

OK - I finally got this working. I also needed the the GNU Scientific Libraries and ran into similar issues with the architecture setting. For anyone interested, this tutorial goes through how to set up Xcode and link libraries:

https://web.archive.org/web/20101006023300/http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31