views:

6737

answers:

5

Hey all,

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

A: 

Did you set these options for the target?

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

robottobor
+2  A: 

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!

Cheers,

Steve

Bids
A: 

Thanks everyone. I tried a couple variations of the two replies and am still getting the same errors. There is also the following warning included:

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

So perhaps Xcode is finding the library but cannot deal with it? Although everything is fine with g++, perhaps FFTW has to be installed differently to work with xcode?

Sounds like you have a library that was not compiled for OS X or is not for your processor (x86 or PPC).
Jay Conrod
+1  A: 

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:

http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31

A: 

I'm running into the same original problem, and am a little confused about the solution. The solution is to change the system architecture? This still hasn't worked for me.

Slamice