0

I've downloaded the GMP multiprecision library and I compiled without errors the following code through the terminal with the gcc main.c -lgmp command but I can't figure out how to include the GMP library in XCode 4.5 because the howtos online are a bit confusing.

I really need to use the GMP library for my projects and any comment would be great help.

#include <stdio.h>
#include <gmp.h>

int main(int argc, const char * argv[])
{
    printf("Hello, World!\n");
    mpz_t a;
    return 0;
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
fpiro07
  • 847
  • 1
  • 13
  • 18
  • It is a bit of a pain in xcode, I would suggest trying to follow one of the many online tutorials. The gist of it is to add the include directory of the library to the project, then add the path to the library to the library search path, then tell the linker to actually link the library. When I get home I might write up a little how to and post it on my blog because it is a common question, I'll post here and let you know if I do. – Chris McCabe Dec 19 '12 at 15:56
  • Yes please write the howto I really need it :D – fpiro07 Dec 19 '12 at 22:08

1 Answers1

0

(Answered in a question edit. Converted to a community wiki answer. See What is the appropriate action when the answer to a question is added to the question itself? )

The OP wrote:

SOLVED

1) Open the left panel, goto "ProjectName", Targets, Build phases, Link binary with libraries and select your library.

2) Open the left panel, goto "ProjectName", Project, Header Search Paths, write the path where the headers of your library are (the .h files, usually in /usr/local/include).

3) Open the left panel, goto "ProjectName", Project, Library Search Paths, write the path where your libraries are (the .a or .dylib files, usually in /usr/local/lib)

Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129