NT/Win32 cross Linux compiler
Thu Jul 1 06:43:00 GMT 1999
Brendan Simon <firstname.lastname@example.org> wrote:
> Kevin Farrell wrote:
> > Hi,
> > I'm trying to build a Win32-hosted Linux-targetting cross-compiler using the
> > Canadian cross compiler process.
> > (2-1) Now I'm wondering where do I get the linker from? Do I use the linker
> > from a Windows installation of the Cygwin32 binaries?
> You can use the cygwin32 linker (ie. ld) but you must use the linker scripts for
> your target and link with libraries compiled for your target.
This isn't possible, the cygwin linker supports only the i386pe-format :
GNU ld version 2.9.4 (with BFD 2.9.4)
but the Linux-binaries need the support for elf_i386 (and for the old i386linux
'aout') format :
GNU ld version 2.9.1 (with BFD 2.9.1)
Building GNU binutils for the i586-cygwin host / i586-linux-gnu target
(or for both the i586-cygwin and i586-linux-gnu targets) is the only way.
> > (2-2) I tried to build the binutils-2.9.1 using the i586-cygwin32
> > Linux->Windows compiler (which I mentioned at the start of this mail), but I
> > get the following error:
> > ../libiberty/libiberty.a ../bfd/.libs/libbfd.a: could not read symbols:
> > Archive has no index; run ranlib to add one
> > I tried running ranlib on libbfd.a but it doesn't make any difference.
Running 'ranlib' is a little misleading info, the 'libiberty.a' and 'libbfd.a'
are libraries for the 'host' to come, i.e. 'cygwin', so handling them with your
'i586-cygwin-ranlib' would have been the right info... But the error messages
are of course always 'generic' and it is assumed that the user knows which
'ranlib' to run.
Anyway the Makefile should have found your 'ar', 'ranlib', 'nm' etc. for the
cygwin target when building the 'libiberty.a' and 'libbfd.a'. I cannot be sure,
because I always define these things when configuring anything. In your case I
would have used a script something like follows :
CC="i586-cygwin32-gcc -m486" \
CFLAGS="-O -Wall" \
./configure --build=i586-linux-gnu --host=i586-cygwin32 \
to configure the binutils sources for 'cygwin32-to-i586-linux-gnu'. The
CC and CFLAGS are used as demonstrations about how to give several options for
Making this kind of 'conf_cygw2linux.sh' script and then running it for
the first time takes just a little more time than writing it straight to a
command line, but when it is available as a template for further configures,
you'll find it very useful. The build system defs are always the same, and if
the host is the same too, just editing the '--target=xxx' is enough. Having a
naming systems helps too, e.g :
conf_linux2cygw2.sh - configures for Linux-to-Cygwin
conf_linux2m68k-coff.sh - configures for Linux-to-m68k-coff
conf_cygw2m68k-coff.sh - configures for Cygwin-to-m68k-coff
conf_cygw2arm-coff.sh - configures for Cygwin-to-arm-coff
Not letting 'configure' to guess anything is always the safe way...
If you want to use the same linker for both the 'i386pe' and 'elf_i386'
formats, just use the '--target=i586-cygwin32 --enable-targets=i586-linux-gnu',
to make your cygwin-hosted binutils to support both the cygwin and linux
formats. But the resulting 'as.exe' doesn't support 'elf_i386' etc. and you
must rebuild 'plain i586-linux-gnu'-target binutils to get the right
'as.exe'... I suggest building the 'plain i586-linux-gnu' binutils first, and
thinking the combination of the native-cygwin and linux-target binutils
later...i.e. your 'universal' linker would the show something like :
GNU ld version 2.9.4 (with BFD 990324)
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
To remove yourself from the crossgcc list, send
mail to email@example.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.
More information about the crossgcc