Building gmp library for the iPhone-Update

Michał spock2 at o2.pl
Thu Jul 16 00:38:36 CEST 2009


Hi,

Are you sure that apple allows native build for iphone?

I am not very familiar with native development for iphone. I have some 
experience with android and stand alone build of GMP for ARM. I will try 
to give you some hints about what I have learned. Maybe that will be useful.

Some time ago I have build GMP for ARM7 core from AT91SAM7 family. This 
was typical stand alone build without linux on board of the 
microcontroller. Because of that I had to setup GNU ARM toolchain on my 
Ubuntu linux and then do a native build of GMP following instructions in 
the manual. Actually most of my problems regarded setting up toolchain 
and after that build of GMP was easy. During this build I have used 
arm-elf-gcc compiler.

But building stand alone application for embedded system is quite 
different than for embedded system with operating system like e.g. linux 
in android platform. As I have mentioned before I do not know anything 
about iphone OS and how the things work there. As far as I know apps are 
written in objective C and I am not exactly sure how to build app that 
uses code written in C (in your case GMP).
Because of my lack of experience in iphone I will give you short 
explanation how it works on android. Overall scheme is probably similar 
(I hope). Android is basically build on linux and because of that you 
need different compiler to build native code (gnu arm eabi or something 
like that). I will not go into details how eabi compiler is different 
from elf compiler but it is and it is important. So first thing to 
remember is that you need different compiler for arm platform running 
operating system. Compiler is not enough and you will actually need more 
tools that compose together toolchain for embedded development. In case 
of android platform it was officially released a few weeks ago and 
before that it was impossible to build “legal” app that would use native 
code.

Then you need a way to join your native code with android app code. In 
this case this is achieved by JNI. No clue how to do it on iphone.
I hope that this will be a little helpful for you. Good luck and let us 
know if you have any success with that.

Kind regards
Michal


Pierre-Henri Jondot pisze:
> Hi,
>
> Following some of the advice in 
> http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html 
>
> I managed to get a bit further in the building of gmp. (At least I got 
> past the configure step...)
>
> I tried two configurations, one for iPhoneOS 2.2 (gcc 4.0.1)
> and one targetting iPhone OS 3.0. (gcc 4.2.1)
>
> In both cases, build fails with at the same spot (here for OS 3.0) with :
>
>  /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1 
> -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. 
> -DOPERATION_invert_limb 
> -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ 
> -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/ 
> -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ 
> -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/ 
> -pipe -no-cpp-precomp -isysroot 
> /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk 
> tmp-invert_limb.s -o invert_limb.o
> tmp-invert_limb.s:56:unsupported relocation on symbol invtab
> tmp-invert_limb.s:56:FATAL:Internal error: incorrect fx_r_type (17) 
> for fx_subsy != 0 in fix_to_relocation_info()
> make[2]: *** [invert_limb.lo] Error 1
> make[1]: *** [all-recursive] Error 1
> make: *** [all] Error 2
>
> Does it ring a bell ?
>
> Regards,
>
> Pierre-Henri
>
>
>
> Le 15 juil. 09 à 12:12, Pierre-Henri Jondot a écrit :
>
>> Hi,
>>
>> I am an iPhone developer, and I do have a project making use of 
>> several libraries (LGPL and GPL), and the gpm library is the first I 
>> am trying to build. (Of course the final project will then have to be 
>> GPL)
>>
>> I browsed the archives to see if others went the same route 
>> previously and couldn't find any.
>>
>> I've failed miserably so far to build the library. My os is OSX 
>> 10.5.7 with iPhone SDK 3.0.
>>
>> What I have tried so far :
>>
>> ./configure --disable-shared --enable-static 
>> --prefix=/Developer/Platforms/iPhoneOS.platform/Developer/usr/local 
>> --build=i686-apple-darwin --host=armv6-apple-darwin 
>> CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2"
>>
>> but doing this seems not enough to cross-compile for arm architecture 
>> (it builds for x86 it seems), and the first asm file triggers an error.
>>
>> Replacing --host=armv6-apple-darwin with --host=none-apple-darwin 
>> allowed me to build a library... but for x86 architecture...
>>
>> Doing :
>>
>> /configure --disable-shared --enable-static 
>> --prefix=/Developer/Platforms/iPhoneOS.platform/Developer/usr/local 
>> --build=i686-apple-darwin --host=armv6-apple-darwin 
>> CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2" 
>> CFLAGS="-arch armv6"
>>
>> fails at the configure step : "could not find a working compiler", 
>> and the config.log shows :
>> configure:3900: 
>> /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 
>> -arch armv6  conftest.c >&5
>> ld: library not found for -lcrt1.o
>>
>> Any idea of what I have been doing wrong ?
>>
>> Regards,
>>
>> Pierre-Henri Jondot
>> _______________________________________________
>> gmp-discuss mailing list
>> gmp-discuss at gmplib.org
>> https://gmplib.org/mailman/listinfo/gmp-discuss
>
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>
> __________ Informacja programu ESET Smart Security, wersja bazy 
> sygnatur wirusow 4243 (20090714) __________
>
> Wiadomosc zostala sprawdzona przez program ESET Smart Security.
>
> http://www.eset.pl lub http://www.eset.com
>
>
>



More information about the gmp-discuss mailing list