tags:

views:

260

answers:

3

(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?

A: 

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

Zitrax
A: 

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.

Stephen Canon
A: 

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.

Rob Keniger