在 Xcode 中链接库

2022-01-11 00:00:00 linker c++ xcode

我使用的是 powerbook (osx 10.5),最近下载并安装了 FFTW 3.2 (link text).我已经能够使用终端根据在线教程编译和运行一些简单的程序:

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

但是,我无法在 Xcode 中编译相同的程序.我收到一个链接错误,未找到符号".在/usr/local/lib 中有一个名为 libfftw3.a 的文件.这怎么可能联系起来?此外,显然这些库必须以特定顺序链接,即参见:链接文本

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

感谢您的帮助

推荐答案

要在 Xcode 中链接到这样的 .a 库,您需要:

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

  • 在 Xcode 中双击您的目标或应用程序以打开信息窗口

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

切换到构建"标签

将 -lfftw3 添加到其他链接器标志"(在链接"下)

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

将库的路径添加到库搜索路径"(在搜索路径"下).在您的情况下,这将是/usr/local/lib

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

我们使用 FFTW(顺便说一句,它很棒),这对我们有用!

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

相关文章