Adding Linker Flags in Xcode

我的未来我决定 提交于 2019-11-30 07:08:25

问题


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

I am trying to compile a program that uses the GMP big number library. But to be able to compile with GMP, I have to add -lgmp to 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 lgmp flag while using Xcode?


回答1:


Right-click the target in the Xcode Groups and Files list and select Get Info from the contextual menu. In the Build tab, type linker into the search field and then locate the Other Linker Flags item.

Double-click the Other Linker Flags item and add -lgmp.




回答2:


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




回答3:


You can just open the folder containing libgmp.a on 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.



来源:https://stackoverflow.com/questions/2125079/adding-linker-flags-in-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!