在 Xcode C++ 项目中链接外部库 [英] Link External Library in Xcode C++ Project

查看:66
本文介绍了在 Xcode C++ 项目中链接外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了这个问题的答案,但它们对我不起作用.我正在尝试在 Xcode 中构建一个 C++ 项目,该项目使用来自 ffmpeg 和 openCV 的外部库,但我不知道如何链接它们.按照建议,我转到构建阶段"屏幕,那里有一个将二进制文件与库链接"的位置.我需要链接的库之一位于/usr/local/lib/libavutil.a.当我尝试添加库时,会弹出一个列表框,显示两个文件夹:OS X 10.11"和Developer Frameworks".我需要的库不在这两个文件夹中.我尝试单击添加其他"并出现一个文件选择器对话框,但是如果我在搜索框中键入/usr/local/lib/libavutil.a",该对话框不接受它.

I've found answers to this question, but they don't work for me. I'm trying to build a C++ project in Xcode that uses external libraries from ffmpeg and openCV, and I can't figure out how to link them. As recommended, I go the "Build Phases" screen, and there's a place for "Link Binary with Libraries." One of the libraries I need to link with is at /usr/local/lib/libavutil.a. When I try to add a library, a list box pops up showing two folders: "OS X 10.11" and "Developer Frameworks". The library I need is not in either of these folders. I tried clicking on "Add Other" and a file chooser dialog comes up, but if I type "/usr/local/lib/libavutil.a" in the search box, the dialog doesn't accept it.

我发现在Build Settings"中的Other linker flags"行输入-lswcale -lavcodec -lavdecice"等是有效的,但这不是我所希望的.我希望得到一个文件选择器对话框,我可以在其中简单地单击我想要使用的库.

I've found that typing '-lswcale -lavcodec -lavdecice' etc. on the "Other linker flags" line in "Build Settings" works, but it's not what I hoped for. I was hoping to get a file chooser dialog, where I could simply click on the libraries I want to use.

有没有办法实现我想要的?

Is there a way to accomplish what I want?

推荐答案

如果我理解您的要求,您只是想在正确的位置设置"文件选择器对话框,对吗?

If I understand correctly what you are asking, you simply want to "set" the file chooser dialog at the right place, right?

如果是这样,您只需在进入文件选择器对话框后按 Cmd + Alt + G,然后单击链接二进制文件与库"中的添加其他..."菜单.将出现转到文件夹:"对话框,您可以在其中键入文件或要查找的文件夹的完整路径.

If so, you just have to press Cmd + Alt + G once you are in the file chooser dialog, after clicking on "Add Other..." in the "Link Binary with Libraries" menu. A "Go to the folder:" dialog comes up, and there you can type the fullpath to the file or the folder you are looking for.

希望有所帮助!

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

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