C++ – Linking Libraries in Xcode

clinkerxcode

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

Best Answer

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!