在 Xcode 中使用额外的 C++ 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1609744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:55:02  来源:igfitidea点击:

Using additional C++ libraries in Xcode

xcode

提问by Roman Prykhodchenko

There is a possibility in MS Visual Studio to go to Tools->Options->Projects and solutions->VC++ Directories and to add header and binary files of additional C++ libraries, and compiler uses them for every project if they are needed. How to achieve such result in Xcode 3.2?

在 MS Visual Studio 中可以转到工具->选项->项目和解决方案->VC++ 目录并添加其他 C++ 库的头文件和二进制文件,如果需要,编译器将它们用于每个项目。如何在 Xcode 3.2 中实现这样的结果?

Thank you!

谢谢!

回答by thomas

Look in the "Link Binary With Libraries" build phase under your target. Right click on it, and select "Existing Files..." -- then select the library you wish to link to. You don't have to use a framework as implied earlier.

查看目标下的“Link Binary With Libraries”构建阶段。右键单击它,然后选择“现有文件...”——然后选择要链接到的库。您不必使用之前暗示的框架。

回答by Johannes Rudolph

XCode uses the concept of a "Framework" for such a purpose. Basically, a "Framework" is header files and libraries in a bundle. You can find more information on frameworks here.

XCode 为此目的使用“框架”的概念。基本上,“框架”是包中的头文件和库。您可以在此处找到有关框架的更多信息。

Add a framework to you project by right clicking your project in XCode and choose "Add framework". Make sure it is also referenced in your build target. The resource above has all necessary information.

通过在 XCode 中右键单击您的项目并选择“添加框架”,向您的项目添加框架。确保在您的构建目标中也引用了它。上面的资源包含所有必要的信息。

回答by the_mandrill

I don't think there's an option to do this automatically for all projects. You have to manually set the include paths, library paths and link flags for each target.

我认为没有一个选项可以为所有项目自动执行此操作。您必须为每个目标手动设置包含路径、库路径和链接标志。

One thing that may work though is to set the standard GCC variables, eg CFLAGS, CXXFLAGS, LDFLAGS which you can set up in /etc/profileor ~/.bash_profile

可能可行的一件事是设置标准 GCC 变量,例如 CFLAGS、CXXFLAGS、LDFLAGS,您可以在其中设置/etc/profile~/.bash_profile