Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Trouble installing gmp library

I am trying to install this gmp library so that my c++ can handle larger numbers. I am using a standard installation method:


./configure

make

make check

make install


The ./configure part is where I am having trouble, it says

error: could not find a working complier, see config.log for details


If anyone needs more information to help I will gladly provide.

MacBook Pro, Mac OS X (10.7.2)

Posted on Apr 8, 2013 5:01 PM

Reply
17 replies

Apr 9, 2013 5:56 AM in response to berrste

Angle brackets (<>) tell the compiler to look for the header file on the standard search paths for the system. It's unlikely that a library you've built yourself will be installed there. In fact, the normal location for programs built using the "./configure, make, make install" idiom is /usr/local.


Therefore, your headers are most likely in /usr/local/include and the corresponding library in /usr/local/lib. You will need to pass those to the compiler, either in Xcode settings (if using Xcode) or using the -I (capital-I), -L and -l (lower-case L) switches (if using the command line or makefiles). In that case, the proper way to include your header file is using double-quotes (#include "gmp.h")

Apr 10, 2013 6:04 AM in response to berrste

Passing through the compiler means to compile the code. g_wolfman is referring C and C++ include-file angle-bracket syntax, and how to explicitly tell the compiler where the system (angle-bracket) includes are actually located in the file system, if the files involved are not in the expected location.


To compile C and C++ code on OS X, ensure the command-line tools are enabled within Xcode.app > Preferences > Downloads > Components. This setting causes Xcode to create the traditional commands used to invoke the compilers and the linker, and these commands are what the shell scripts and configure scripts generally expect. Now run those build and configuration scripts again.


If those configuration scripts fail, then you will have to do some work porting gmp to OS X, figuring out what happened with the script. Alternatively, the homebrew tool — a package installer for OS X — can a previously-ported version, and it looks like homebrew does have a recipe for gmp.


Though it's probably a little late for this, it's also good practice to have a backup of your system before starting to work with an open-source configure script, as not all of the scripts will work or will work on OS X, and not all of the scripts will "play nice" with the file system and existing system tools and libraries. Files, libraries and header files can be overwritten by some configure scripts, and that can cause dependent software elsewhere in OS X to fail.

Nov 4, 2013 12:12 PM in response to berrste

I am trying to use GMP in Xcode I followed the steps below to link the library:

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)

but when I am using mpz_init (); function Xcode reported undefined reference to __gmpz_init error any idea on how to resolve this error

Nov 4, 2013 1:22 PM in response to malbahri

OK: so the text that malbahri has posted here appears to be extracted from this StackOverflow question.


I'm assuming you're using some version of Xcode4 or Xcode 5. If so, I'd expect to have to reference the libgmp bits within the Xcode link and search path settings. This is what Frank Caggiano referenced. Here's a longer StackOverflow discussion on this topic, with some more details.

Nov 4, 2013 3:29 PM in response to MrHoffman

Thank you Hoffman for your reply.


I went through suggested stackoverflow. However I may need to give more information about what I have done so far. First of all I am using embedxcode installed in xcode 4.6.3. The gmp library installed in /usr/local/cellar/gmp/5.1.3. When I tried to Link binary with libraries I selected index as there is no option for Build phase in the project Tab and this shown in the below picture


User uploaded file

Then I added the libgmp.dylib as it can be seen below:


User uploaded file

User uploaded file

Accrodingly I added the header search path and library search as shown in the picture below


User uploaded file

Then i tried to build all but now I am getting different error which says the gmp.h no such file or directory depsite it shows me when I am start call gmp function in the library is reponding as shown below


User uploaded file

I hope you can guide me solving this error as I am new to the xcode.

Nov 4, 2013 4:00 PM in response to malbahri

malbahri wrote:


Thank you Hoffman for your reply.


I went through suggested stackoverflow. However I may need to give more information about what I have done so far. First of all I am using embedxcode installed in xcode 4.6.3. The gmp library installed in /usr/local/cellar/gmp/5.1.3. When I tried to Link binary with libraries I selected index as there is no option for Build phase in the project Tab and this shown in the below picture

This is a Makefile-based project. I think you will have to edit the Makefile to add -L/usr/local/cellar/gmp/5.1.3 -lgmp or something like that.

Trouble installing gmp library

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.