Cross-compiling/porting to Linux

Michael Hopkins michael.hopkins at hopkins-research.com
Wed Mar 30 03:39:46 PST 2005


On 30/3/05 5:22 am, "Axel Gonzalez" <loox at e-shell.net> wrote:

> On Tuesday 29 March 2005 05:32, Michael Hopkins wrote:
>> Hi all
>> 
>> I have just installed mingwin32 from the ports and it works beautifully -
>> can now port all my Unix command line code (including linking to win32
>> libraries) to win32 with the flick of a make switch.  Marvellous!
> 
> Glad to know it works now.. I should have checked more often
> 
Hi Axel

Seems to work well but not tested exhaustively across different code and
Windows versions yet.

>> 
>> Now to linux...  I haven't tried any of the linux compatibility stuff yet,
>> either for running binaries or cross-compiling.  I thought I would ask here
>> first because I have seen quite a few messages suggesting potential issues
>> on amd64.
>> 
>> At the moment I am mainly interested in cross-compiling and wanting to
>> target 32-bit linux, but obviously 64-bit will be useful in the future.
>> Would like to get some advice on what to install and any kernel
>> configuration or module loading that I might need to do.
> 
> This should be well documented elsewhere, if i remember correctly:
> 
> on kernel, add the options:
> 
> options         LINPROCFS
> options         COMPAT_43
> options         COMPAT_LINUX32
> 
> Install the emulators/linux_base-8 port
> 
> and enable on rc.conf
> 
> linux_enable="YES"
> 
> After that you should have a running linux enviroment
> 
> $ /compat/linux/bin/bash
> $ uname -a
> Linux moonlight 2.4.2 FreeBSD 5.3-STABLE #0: Thu Feb  3 23:08:02 CST 2005
> amd64 amd64 amd64 GNU/Linux
> 
Did exactly these steps and got this far at 4:30am this morning!  :o}

root at Athlon ~ # cd /compat/linux/bin
root at Athlon /compat/linux/bin # ./uname -a
Linux Athlon 2.4.2 FreeBSD 5.3-RELEASE-p5 #2: Wed Mar 30 01:46:52 BST 2005
amd64 amd64 amd64 GNU/Linux

> 
> Then, the real thing, the cross compile
> 
> NOTE: At this point I'm guessing, tell us if it works ;)
> 
> Get a GCC RPM and install it (check the Makefile on the linux port, to see the
> flags it uses, and see you dont overwrite system GCC)
> 
This is where I got badly stuck, though I might have the answer - see below.
 
I first tried about 10 RPMs from various places that are meant to be for
Redhat 8 on i386 (or i586 or i686 - I am guessing it shouldn¹t matter?) and
whenever I try to install them with the recommended command, e.g. :

rpm -i --ignoreos --root /compat/linux --dbpath /var/lib/rpm
/mnt/Desktop/apt-0.5.5cnc6-fr0.rh80.1.i386.rpm

I get this message:

 "package apt-0.5.5cnc6-fr0.rh80.1 is for a different architecture"

I then thought that the recently-installed linux rpm might be the right way
to deal with this, so:

/compat/linux/bin/rpm -i --ignoreos --root /compat/linux --dbpath
/var/lib/rpm /mnt/Desktop/apt-0.5.5cnc6-fr0.rh80.1.i386.rpm

warning: /mnt/Desktop/apt-0.5.5cnc6-fr0.rh80.1.i386.rpm: V3 DSA signature:
NOKEY, key ID e42d547b
error: Failed dependencies:
        rpm >= 4.0.0 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libstdc++ is needed by apt-0.5.5cnc6-fr0.rh80.1
        /sbin/ldconfig is needed by apt-0.5.5cnc6-fr0.rh80.1
        /bin/sh is needed by apt-0.5.5cnc6-fr0.rh80.1
        libbz2.so.1 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.0) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.1) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.1.3) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.2) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.2.3) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libc.so.6(GLIBC_2.3) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libelf.so.0 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libgcc_s.so.1 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libgcc_s.so.1(GCC_3.0) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libm.so.6 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libncurses.so.5 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libpopt.so.0 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libpthread.so.0 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libpthread.so.0(GLIBC_2.0) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libpthread.so.0(GLIBC_2.1) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libreadline.so.4 is needed by apt-0.5.5cnc6-fr0.rh80.1
        librpm-4.1.so is needed by apt-0.5.5cnc6-fr0.rh80.1
        librpmdb-4.1.so is needed by apt-0.5.5cnc6-fr0.rh80.1
        librpmio-4.1.so is needed by apt-0.5.5cnc6-fr0.rh80.1
        librt.so.1 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libstdc++.so.5 is needed by apt-0.5.5cnc6-fr0.rh80.1
        libstdc++.so.5(GLIBCPP_3.2) is needed by apt-0.5.5cnc6-fr0.rh80.1
        libz.so.1 is needed by apt-0.5.5cnc6-fr0.rh80.1

Even though all of these executables and libraries are installed as standard
in linux_base-8.

Then another thought; use '--ignorearch' with the FreeBSD rpm command. This
seems to install linux apt as required!  :o)  Maybe this is the right way to
go?  I will investigate further and let you know.

> Maybe some extra RPMs.. make, libtool etc
> 
> Run gcc from the linux bash (check the path to be sure its really using
> linux's gcc)
> 

Will try these later today.

> *IF* this work, you should be able to compile and run linux32 programs (you
> using a linux compiler right ?)
> 

So I can't get to these steps until I have worked out how to install the GCC
tools for linux.  As far as I can tell I have the following options:

1) Work out how to make RPMs work as discussed above.  Would like this
anyway to be able to use more linux stuff.

2) Install linux_devtools from ports - but:
/usr/ports/devel/linux_devtools % make
===>  linux_devtools-8.0_3 is only for i386, and you are running amd64.

3) Find a tarball of the GCC toolset for RH8 i*86 and extract it into
/compat/linux

4) ? Any others ?

> For linux64, well first step is to get binaries working
> 
I will just be happy to have 32-bit working for now!

Thanks for the input

Michael



_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

        _/    _/   _/_/_/             Hopkins Research Ltd
       _/    _/   _/    _/
      _/_/_/_/   _/_/_/          http://www.hopkins-research.com/
     _/    _/   _/   _/
    _/    _/   _/     _/               'touch the future'
                   
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/




More information about the freebsd-amd64 mailing list