Thursday 18 November 2010

gcc and gmp and mac

This is only relevant if you have a mac and want to use libgmp (gnu multi precision library), with perl.

My problems were as follows:
a) the default c compiler was giving me grief.
b) In CPAN, the library by default was not being detected even though it was being built.
c) going out of cpan and doing things 'manually' allowed me to specify the directory the library was installed in.
d) the architecture was still wrong. (because my perl was 32 bit)

1. gcc 4.0 is not supported. gcc 4.2 is..
make clean
CC=gcc-4.2 CXX=g++4.2 ./configure
make
make check
[tests pass, -m64 is visible in libtool]
sudo make install
file usr/local/
file /usr/local/lib/libgmp.10.dylib
/usr/local/lib/libgmp.10.dylib: Mach-O 64-bit dynamically linked shared library x86_64

2. CC=gcc-4.2 CXX=g++4.2 CFLAGS='-m64' ./configure
file /usr/local/lib/libgmp.10.dylib
/usr/local/lib/libgmp.10.dylib: Mach-O 64-bit dynamically linked shared library x86_64

(no change.. the problem is we want to link with a 32 bit perl, partly because that's the system provided one, partly because I don't want to recompile perl at this stage).

3. CC=gcc-4.2 CXX=g++4.2 CFLAGS='-m32' ./configure
..
configure: error: Oops, mp_limb_t is 32 bits, but the assembler code
in this configuration expects 64 bits.

...
reading
info ./doc/gmp.info

"By default GMP chooses the best ABI available for a given system,
and this generally gives significantly greater speed. But an ABI can
be chosen explicitly to make GMP compatible with other libraries, or
particular application requirements. For example,

./configure ABI=32
"
...
so..

4. CC=gcc-4.2 CXX=g++4.2 CFLAGS='-m32' ./configure ABI=32
make
make check
[all going well]
sudo make install
mw6$ file /usr/local/lib/libgmp.10.dylib
/usr/local/lib/libgmp.10.dylib: Mach-O dynamically linked shared library i386

that looks like a win.
Now try and install math::bigint::gmp in perl...
>perl512 ./Makefile.PL INC="-I/usr/local/include" LIBS="-L/usr/local/lib -lgmp"
Writing Makefile for Math::BigInt::GMP
>make
>make test
t/bigfltpm.t .. ok
t/bigintg.t ... ok
t/bigintpm.t .. ok
t/biglog.t .... ok
t/bigroot.t ... ok
t/pod.t ....... ok
t/pod_cov.t ... ok
t/storable.t .. ok
t/threads.t ... skipped: Perl compiled without ithreads
All tests successful.
Files=9, Tests=5537, 4 wallclock secs ( 0.64 usr 0.06 sys + 3.84 cusr 0.14 csys = 4.68 CPU)
Result: PASS

> sudo make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /Users/mw6/usr/local/lib/perl5/site_perl/5.12.0/darwin-2level/auto/Math/BigInt/GMP/GMP.bs
Installing /Users/mw6/usr/local/lib/perl5/site_perl/5.12.0/darwin-2level/auto/Math/BigInt/GMP/GMP.bundle
Installing /Users/mw6/usr/local/lib/perl5/site_perl/5.12.0/darwin-2level/Math/BigInt/GMP.pm
Installing /Users/mw6/usr/local/share/man/man3/Math::BigInt::GMP.3
Appending installation info to /Users/mw6/usr/local/lib/perl5/5.12.0/darwin-2level/perllocal.pod


WIN!

Relevant Links:
GMP: The GNU Multiple Precision Arithmetic Library
Math::BigInt::GMP: Use the GMP library for Math::BigInt routines (v1.32 23 Sept 2010)

Wednesday 21 April 2010

ARAnyM (finally!)


So I've finally got aranym up and running with network support.

I'm running it on a mac. Took a bit of reading the documentation. And then reading it again.

Useful notes & Difficulties:-

  • Networking works once, then after quitting Aranym, it won't work again until I restart the mac. Nothing on google about the error messages. You'll know if it might work if you're asked for the admin password.
  • Getting Easymint installed from two downloaded partitions meant that my native boot files needed moving to drive E:
  • Which meant editing a few config files, to change paths.
  • jit compiler is 10x faster, but seems to have trouble running the included (kronos) benchmarking software
  • my mouse won't leave the atari screen, so check the keyboard configuration page for macs.. [aranym wiki] which tells me, if I've got the config right its 'left shift left ctrl left alt' oh well that still isn't working.


Useful config bits:

~/Documents/Aranym_files/config

...
[ETH0]
Type = ptp
Tunnel = tap1
HostIP = 172.16.1.8
AtariIP = 172.16.1.9
Netmask = 255.255.255.0
MAC = 00:41:45:54:48:30
...
on the (Atari) command line:
>ifconfig eth0 addr 172.16.1.9 netmask 255.255.255.0
>route add default eth0: gw 172.16.1.8

I suspect there's plenty more questions about getting this working

Here are some useful links:
Get ARAnyM
ARAnyM project page
emutos- a free rom which you will need unless you have a falcon
useful atari desktop software -- the file afros812.zip contains drive_c and all the apps like xaaes, some fonts and highwire, the web-browser.
aranym wiki - help you with the config file, some potentially confusing information here.. !! Read the documentation that came with the download to get networking to work !!
easymint gives you all the freemint stuff (ie; all the unix style software you love eg; grep, a newer bash, perl 5.6)
tuntap for creating that virtual network you might(*) need to create the atari network. !! Read the documentation that came with your aranym download !!
*Alternatively there is a direct connection option.. thanks to Philipp Donzé hopefully I'll get that working soon ;-)