C语言 在 Xcode 中添加链接器标志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2125079/
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-02 04:13:48  来源:igfitidea点击:

Adding Linker Flags in Xcode

cxcodegmp

提问by Michael Dickens

(I'm not sure if "flag" is the word I'm looking for, but I'll explain it.)

(我不确定“flag”是否是我要找的词,但我会解释一下。)

I am trying to compile a program that uses the GMPbig number library. But to be able to compile with GMP, I have to add -lgmpto the end of the command. For example, if I want to compile "program.c", I have to type gcc program.c -lgmp. This is easy from the command line, but I don't see how to do it in Xcode. How can I add the lgmpflag while using Xcode?

我正在尝试编译一个使用GMP大数库的程序。但是为了能够使用 GMP 进行编译,我必须添加-lgmp到命令的末尾。例如,如果我想编译“program.c”,我必须输入gcc program.c -lgmp. 从命令行这很容易,但我不知道如何在 Xcode 中做到这一点。如何lgmp在使用 Xcode 时添加标志?

回答by Rob Keniger

Right-click the target in the Xcode Groups and Fileslist and select Get Infofrom the contextual menu. In the Buildtab, type linkerinto the search field and then locate the Other Linker Flagsitem.

右键单击 Xcode Groups and Files列表中的目标,然后从上下文菜单中选择Get Info。在“构建”选项卡中,linker在搜索字段中键入,然后找到“其他链接器标志”项。

Double-click the Other Linker Flagsitem and add -lgmp.

双击其他链接器标志项并添加-lgmp.

回答by Zitrax

Maybe this helps:

也许这有帮助:

You can also open the active target's preferences, and click the "General" tab. You can add the library to be linked inside that tab, in the "Linked Libraries" section at the botton.

您还可以打开活动目标的首选项,然后单击“常规”选项卡。您可以在该选项卡中的“链接库”部分中添加要链接的库。

Taken from http://www.soulstorm-creations.com/PROJECT_SOULSTORM_2_0/programming-articles/installing-portable-libraries-on-os-x.html

取自http://www.soulstorm-creations.com/PROJECT_SOULSTORM_2_0/programming-articles/installing-portable-libraries-on-os-x.html

回答by Stephen Canon

You can just open the folder containing libgmp.aon your system (/usr/local/lib/for a default install), and drag the library out of the folder onto the target that you want it to get linked into. There are several other ways as well, such as the one suggested by Zitrax.

您只需打开libgmp.a系统上包含的文件夹(/usr/local/lib/对于默认安装),然后将库从文件夹中拖到您希望它链接到的目标上。还有其他几种方法,例如Zitrax建议的方法