cvs commit: hints lin2win.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Mon Jul 21 11:38:19 PDT 2003


timothy     03/07/21 12:38:19

  Added:       .        lin2win.txt
  Log:
  Initial commit.
  
  Revision  Changes    Path
  1.1                  hints/lin2win.txt
  
  Index: lin2win.txt
  ===================================================================
  TITLE:		Linux to Windows 
  LFS VERSION:	LFS CVS
  AUTHOR:		Nathan Coulson <conathan at conet.dyndns.org>
  		Seth W. Klein <>
  SYNOPSIS:
          Ever want to compile windows programs from linux?  This hint shows
  you how to build i386-pc-mingw32, i386-pc-cygwin32, and i386-pc-msdosdjgpp
  cross compilers.
  
  VERSION:	0.0.2
  CHANGELOG:
          0.0.2: Added i386-pc-cygwin32.
          0.0.1: Added i386-pc-mingw32.
  
  HINT:
          First, to cover some of the basics. To compile the libraries for the
  above compilers, you need the compilers, but to compile the compilers, you
  need the libraries.  This circular dependency is solved by starting with
  binary versions of the libraries.
  
          I am going to define some variables for use in the commands below,
  and you may edit them as you see fit.  PREFIX is the destination directory,
  while TARGET is the type of compiler you wish to install.
  
  i386-pc-mingw32 [binary libraries]
  ==================================
  FILES:
          binutils-2.13.2.tar.bz2		[ftp://ftp.gnu.org/gnu/binutils]
          gcc-3.2.3.tar.bz2		[ftp://ftp.gnu.org/gnu/gcc]
          mingw-runtime-3.0.tar.bz2	[http://www.sf.net/projects/mingw]
          w32api-2.3.tar.bz2		[http://www.sf.net/projects/mingw]
  
  ENV:
          PREFIX=/opt/cross-compile_bin
          TARGET=i386-pc-mingw32
  	export PATH=$PREFIX/bin:$PATH
  
  BINUTILS:
          binutils does not appear to require any libraries to compile itself, so
  we install it first.
  
          tar -xjf binutils-2.13.2.tar.bz2
          mkdir binutils-build
          cd binutils-build
          ../binutils-2.13.2/configure --prefix=$PREFIX --target=$TARGET
          make
          make install
  
  LIBRARIES:
  
          These must be installed into the correct directories, so we use tar's
  -C option to specify the destination.
  
  tar -xjf mingw-runtime-3.0.tar.bz2 -C $PREFIX/$TARGET
  tar -xjf w32api-2.3.tar.bz2 -C $PREFIX/$TARGET
  
  GCC:
  	We install GCC last, as it needs the above libraries to compile.
  
  tar -xjf gcc-3.2.3.tar.bz2
  mkdir gcc-build
  cd gcc-build
  ../gcc-3.2.3/configure --prefix=$PREFIX --target=$TARGET \
          --enable-threads=win32 --enable-languages=c,c++ \
          --enable-version-specific-runtime-libs
  make
  make install
  
  END:
          To use your new cross-compiler, put $PREFIX/bin first in your PATH.
  	(It will already be there if you set the variables as above.) In
  	addition, when building a package configured with autoconf, pass
  	--host=$TARGET to the configure script.
  
  	If you want to try it out, type in the following
  
  echo 'main() { puts("Hello World"); }' > test.c
  $TARGET-gcc test.c -o test.exe
  
   	Copy this to a windows machine (if avaliable), and run it.  (It
  should print "Hello World" to the screen before exiting).
  
  i386-pc-mingw32 [compiled libraries]
  ====================================
  FILES:
          binutils-2.13.2.tar.bz2         [ftp://ftp.gnu.org/gnu/binutils]
          gcc-3.2.3.tar.bz2               [ftp://ftp.gnu.org/gnu/gcc]
          mingw-runtime-3.0-src.tar.bz2   [http://www.sf.net/projects/mingw]
          w32api-2.3-src.tar.bz2          [http://www.sf.net/projects/mingw]
    * Note that we use the source code of the 2 libraries this time
  
  ENV:
          PREFIX=/opt/cross-compile 
          TARGET=i386-pc-mingw32
  	export PATH=$PREFIX/bin:$PATH
    * We have changed the prefix to /opt/cross-compile, as to make a fresh install
  
  LIBRARIES:
  	Since we now have a i386-pc-mingw32 toolchain, we can install the
  libraries.  We move w32api-2.3 to w32api, because mingw-runtime searches for
  header files in ../w32api/include.  [you can watch the packages as it compiles
  to verify this].  We install to $PREFIX/$TARGET, as the libraries do not install
  themselves to the $TARGET directory by default, and if we installed to /usr,
  this would overwrite our default headers.  I also had to override the programsi
  that configure uses by default on mingw-runtime, for it does not appear to use
  the --target flag.
  
          tar -xjf mingw-runtime-3.0-src.tar.bz2
          tar -xjf w32api-2.3-src.tar.bz2
          mv w32api-2.3 w32api
          mkdir mingw-build
          cd mingw-build
          ../mingw-runtime-3.0/configure --prefix=$PREFIX/$TARGET --target=$TARGET
          make CC="i386-pc-mingw32-gcc" DLLTOOL="i386-pc-mingw32-dlltool" \
              AS="i386-pc-mingw32-as" AR="i386-pc-mingw32-ar" \
              LD="i386-pc-mingw32-ld" RANLIB="i386-pc-mingw32-ranlib"
          make install
          cd ..
          mkdir w32api-build
          cd w32api-build
          ../w32api/configure --prefix=$PREFIX/$TARGET --host==$TARGET
          make
          make install
          cd ..
  
  BINUTILS:
  	The above instructions are sufficient.
  
  GCC:
  	The above instructions are sufficient.
  
  END:
  	The compiled version should work the same way as the binary way
  
  i386-pc-cygwin32 [binary libraries] (Untested)
  ===================================
  FILES:
          binutils-2.13.2.tar.bz2         [ftp://ftp.gnu.org/gnu/binutils]
          gcc-3.2.3.tar.bz2               [ftp://ftp.gnu.org/gnu/gcc]
          cygwin-1.3.22-1.tar.bz2		[http://www.cygwin.com/mirrors.html]
          w32api-2.3.tar.bz2              [http://www.sf.net/projects/mingw]
    * I got w32api-2.3 from mingw, and just used it for cygwin.  seems to work...
  
  ENV:
          PREFIX=/opt/cross-compile_bin
          TARGET=i386-pc-cygwin32
          export PATH=$PREFIX/bin:$PATH
  
  BINUTILS:
          tar -xjf binutils-2.13.2.tar.bz2
          mkdir binutils-build
          cd binutils-build
          ../binutils-2.13.2/configure --prefix=$PREFIX --target=$TARGET
          make
          make install
  
  LIBRARIES:
  	[FIX: compiled version installs w32api headers to include/winsup, and
  libraries to lib/winsup.  Test to see if this is required].  There also appears
  to be junk we do not need within the cygwin include files [test compiler first].
  
  mkdir tmp
  tar -xjf cygwin-1.3.22-1.tar.bz2 -C tmp
  cp -a tmp/usr/include/* $PREFIX/$TARGET/include
  cp -a tmp/usr/lib/* $PREFIX/$TARGET/lib
  tar -xjf w32api-2.3.tar.bz2 -C $PREFIX/$TARGET
  
  GCC:
          [recheck --enable-threads value]
  
          tar -xjf gcc-3.2.3.tar.bz2
          mkdir gcc-build
          cd gcc-build
          ../gcc-3.2.3/configure --prefix=$PREFIX --target=$TARGET \
              --enable-threads=win32 --enable-languages=c,c++ \
              --enable-version-specific-runtime-libs
          make
          make install
  
  END:
          To use your new cross-compiler, put $PREFIX/bin first in your PATH.
          (It will already be there if you set the variables as above.) In
          addition, when building a package configured with autoconf, pass
          --host=$TARGET to the configure script.
  
          If you want to try it out, type in the following
  
  echo 'main() { puts("Hello World"); }' > test.c
  $TARGET-gcc test.c -o test.exe
  
          Copy this to a windows machine (if avaliable), and run it.  (It
  should print "Hello World" to the screen before exiting).  Please note that
  you require the cygwin environment for windows, downloadable at www.cygwin.com.
  The advantage of cygwin over windows, is that most linux programs could probably
  be easly compiled for cygwin.  [I believe it is posix compliant (research)]
  
  i386-pc-cygwin32 [binary libraries] (Untested)
  ==============================================
  FILES:
          binutils-2.13.2.tar.bz2         [ftp://ftp.gnu.org/gnu/binutils]
          gcc-3.2.3.tar.bz2               [ftp://ftp.gnu.org/gnu/gcc]
          cygwin-1.3.22-1-src.tar.bz2      [http://www.cygwin.com/mirrors.html]
          w32api-2.3-src.tar.bz2           [http://www.sf.net/projects/mingw]
    * again, I got w32api-2.3 from mingw, and just used it for cygwin.  seems to 
  work...
  
  ENV:
          PREFIX=/opt/cross-compile
          TARGET=i386-pc-cygwin32
          export PATH=$PREFIX/bin:$PATH
  
  LIBRARIES:
          It appears that the cygwin libraries behave better then the mingw ones
  do, and a simple --prefix=$PREFIX should install nicely.  It even uses
  the correct programs to recompile itself.  w32api is automatically compiled
  when you add it to the winsup directory, and the cygwin sources will
  not compile without it, afaik.
  
  tar -xjf cygwin-1.3.22-1-src.tar.bz2
  tar -xzf w32api-2.3-src.tar.gz
  mv w32api-2.3 cygwin-1.3.22-1/winsup/w32api
  
  mkdir cygwin-build
  cd cygwin-build
  ../cygwin-1.3.22-1/configure --prefix=/usr --target=$TARGET
  make
  make install
  cd ..
  rm -rf cygwin-1.3.22-1 cygwin-build
  
  BINUTILS:
          The above instructions are sufficient.
  
  GCC:
          The above instructions are sufficient.
  
  END:
          The compiled version should work the same way as the binary way
  
  
  TODO
  ====
  i386-pc-cygwin32: (Test, Simplify Directions).
  i386-pc-mingw32: (Test, Simplify Directions).
  i386-pc-msdosdjgpp: add
  
  The above has not been checked for errors.
  
  Recheck flags for binutils and gcc, cross referenced with LFS's package
  instructions.
  
  Grab LFS's cvs #.
  
  Setup a bootstrap thing, so that binary versions are not installed to wanted
  path.
  
  gcc, I noticed like to stick C++ libraries under the /include directory.  I
  dont know if that is good or not, so I used
  --enable-version-specific-runtime-libs to counteract this.  (It was probably
  a typo, and was my fault though.  I'll double check someday).
  
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe hints' in the subject header of the message



More information about the hints mailing list