I was wondering if anyone has ever worked with the gmp4osx found here in order to create a framework for iOS. I had managed to get it up and running, about four months ago, but then accidentally deleted the folder and now when I follow the instructions to re-build it, I cannot get the gmp-iPhoneOS.h
or gmp-iPhoneSimulator.h
files in the libgmp.framework
folder that is output by the procedure.
I remember that in the past, I just dragged and dropped the libgmp.framework
folder in my project and imported the gmp.h
file in my ViewController class and everything worked smoothly. The main goal of this file is to import the proper gmp-*
file in the project, depending on the target OS. So in case of iPhone it will import the gmp-iPhoneOS.h
. But this file does not exist on my hard drive!
If anyone could please point out a solution, I would really appreciate it! If not, just try to build it on your Mac and see if you get these files (might be a compiler error on my machine, or something else - that I doubt though, since I have tried on a clean installation as well).
Thank you in advance :)
OK got it working! If anyone wants GMP for iOS (or even OSX), just follow the steps below. The problem is that the build script is created for iOS 5.1 and today we need it working for 6.1! The answer was in the Issues tab of github. Can't believe I didn't see it coming!
So here it goes:
Download and extract the gmp4osx project
Open up and edit gmp4osx-master/libgmp/gmp4osx
On line 19 it says IOSVERSION=5.1
, change it to IOSVERSION=6.1
Save the file
Browse to that directory with terminal and type in ./gmp4osx -b
Drag and drop the folder gmp4osx-master/libgmp/build/libgmp.framework
in your project
Import the headers (sample code following) and you have GMP for any platform :)
If you don't know how to import the header files, simply copy and paste the following code and you will have it working!
#import "ViewController.h"
#import "libgmp/gmp.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
mpz_t x;
mpz_init_set_ui(x, 2);
mpz_pow_ui(x, x, 5);
gmp_printf("%Zd", x);
//NSString *c;
//mpz_get_str(&c, 10, x);
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end