Linking GMP to Xcode 4.5

2020-02-15 08:53发布

问题:

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;
}

回答1:

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