Adding Linker Flags in Xcode

Michael Dickens picture Michael Dickens · Jan 24, 2010 · Viewed 32.6k times · Source

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

Answer

Rob Keniger picture Rob Keniger · Jan 26, 2010

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.