Search code examples
compilationopen-sourcearmgmpomap

Cross Compile GMP and Openswan for ARM on Ubuntu 12.04 32 Bit


I have to cross compile opensawn for a OMAP4 Board and GMP is prerequisite. First I tried it on 64 bit OS but it gave me this error:

configure: error: Oops, mp_limb_t is 64 bits, but the assembler code in this configuration expects 32 bits.

Then I shifted to Ubuntu 12.04 32 Bit and the GMP V6.0.0 got compiled after few trials. Even after having the ARCH, TOOLCHAIN and CROSS_COMPILER variables in .bashrc I had to export the following:

export ARCH=arm<BR>
export PATH=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/bin/:$PATH<BR>
export CROSS_COMPILE=arm-none-linux-gnueabi-<BR>

Then following commands were observed:

./configure --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --prefix=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/

make clean
make
make install

Then Soft-linking GMP Library to Toolchain

~/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/lib/gcc/arm-none-linux-gnueabi/4.7.3  
# ln -s ~/Work/Projects/BSQ_VVDN/packages/gmp-6.0.0/.libs/libgmp.so libgmp.so

I had the GMP compiled successfully although the make check reported all test failed.

9 of 9 tests failed.

Now when I try to cross compile Openswan-2.6.41 after making changes in CROSSCOMPILE.sh and do this make programs I get this error:

In file included from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/certs.h:24:0,from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/lib/libopenswan/id.c:42: /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/secrets.h:20:41: fatal error: gmp.h: No such file or directory compilation terminated

I have gone to TI E2E site for this, sniffed internet for pointers in last 4 weeks but I couldn't figure out. If anyone has any clue about cross compiling openswan and GMP for ARM please advise me.


Solution

  • So essentially

    • The static linkage of gmp files had to be done sans sudo - since when you call make programs from openswan package without sudo you are not root instead a normal user and if you use make programs with sudo it misses some exported variables particularly ARCH. It takes the default architecture instead of target architecture you want to compile for; like in my case it was for arm.
    • If you have to use the sudo, make it readable-writeable for all. That is after linking the library files in the toolchain you can call chmod 777 on that file - because then it will be available for rw for all user groups.