在 Xcode 中链接库 [英] Linking Libraries in Xcode

查看:18
本文介绍了在 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!

这篇关于在 Xcode 中链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆