#!/bin/pseudo-sh # where are the sources TAR_FILE_DIR=/somewhere/you/downloaded/all/the/sources # where should be everything installed DESTINATION=/site.opt/mingw32-cross # target platform TARGET=mingw32 # where to build BUILD_ROOT=/tmp/build-native-cross-tstamp # end of configuration section mkdir -p $BUILD_ROOT mkdir -p $DESTINATION/$TARGET cd $DESTINATION/$TARGET tar xzf $TAR_FILE_DIR/mingw-runtime-3.1.tar.gz tar xzf $TAR_FILE_DIR/w32api-2.4.tar.gz cd $BUILD_ROOTOk, now start building binutils
mkdir binutils-build tar xzf $TAR_FILE_DIR/binutils-2.14.90-20030807-1-src.tar.gz cd binutils-build ../binutils-2.14.90-20030807-1/configure --prefix=$DESTINATION --target=$TARGET make && make installNow start building gcc (please adjust the configure options as needed, e.g. I only need C,C++ and Java as languages, you might need other too).
# be sure, that new binutils are in path PATH=$TARGET/bin:$PATH mkdir gcc-build tar xjf $TAR_FILE_DIR/gcc-3.3.1.tar.bz2 cd gcc-3.3.1 gzip -d $TAR_FILE_DIR/gcc-3.3.1-20030804-1-src.diff.gz patch -p1 < $TAR_FILE_DIR/gcc-3.3.1-20030804-1-src.diff cd ../gcc-build ../gcc-3.3.1/configure --target=mingw32 --prefix=/site.opt/mingw32-cross --without-newlib --enable-shared --enable-libgcj --enable-threads=win32 --enable-languages=c,c++,java --disable-nls --disable-debug --with-gcc --with-gnu-as --with-gnu-ld --without-newlib --disable-win32-registry --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-sjlj-exceptions make && make installOk, now you should have got compiled and installed the most basic requirements in a crossed environment. We will need a shared libgcj.dll and after that we are ready to compile the other libraries.
cd mingw32/libjava find . -name "*.o" | uniq > objectlist # now have a sharp look at the objectlist and remove entries that might be the same file, # but at a different location, e.g. .../.libs/<foo> and .../<foo> is such an candidate. mingw32-gcj -shared `cat objectlist` -o libgcj.dll -Wl,--out-implib,libgcj.dll.a -Wl,--export-all-symbols -Wl,--enable-runtime-pseudo-reloc -Wl,--allow-multiple-definition cp libgcj.dll* $DESTINATION/mingw32/libActually I not exactly know, how to work with the generated import lib correctly, but to be sure, that the old static libgcj.a is not used, I rename it to libgcj.b and now you would have to use the importlib, but I will have to ask some other, on how to use that importlib correctly. We will use the dll itself, so it should not matter for the moment.
mv $DESTINATION/mingw32/lib/libgcj.a $DESTINATION/mingw32/lib/libgcj.bSo, we have created a dynamic libgcj.dll. :) Now you are ready with the most needed things to create shared dll's and shared executables.
package test;
void main(String[] args) {
System.out.println("Hello, World");
}
and let it compile
nicec --sourcepath src --destination targets test -a test.jarThat will create a test.jar that is an executable jar archive. This file you can now compile to a native executable through gcj
mingw32-gcj --shared -o libhello.dll test.jar -Wl,--out-implib,libhello.dll.a -Wl,--enable-runtime-pseudo-reloc mingw32-gcj --main=test.fun -o hello.exe -L. -lhello -lgcj -Wl,--enable-runtime-pseudo-relocQuite easy, isn't it.
jar xf test.jar jar cf nice.jar gnu nice mingw32-gcj --shared -o libnice.dll nice.jar -Wl,--out-implib,libnice.dll.a -Wl,--enable-runtime-pseudo-relocThen you can create the executable hello.exe also as follows:
mingw32-gcj --main=test.fun --classpath=nice.jar -o hello.exe test/*.class -L. -lnice -lgcj
mingw32-gcj --shared -o libjavax-crypto.dll javax-crypto.jar -Wl,--out-implib,libjavax-crypto.dll.a -Wl,--enable-runtime-pseudo-reloc mingw32-gcj --shared --classpath=javax-crypto.jar -o libgnu-crypto.dll gnu-crypto.jar -Wl,--out-implib,libgnu-crypto.dll.a -Wl,--enable-runtime-pseudo-reloc
cd poi-2.0-pre3/src/java mkdir ../targets javac -d ../targets org/apache/poi/hssf/usermodel/HSSFWorkbook.javaNow we should have all classes needed for the HSSF part of POI in the targets directory. We could now jar all these classes up and then again create a dll from it, but now we use the old style:
cd ../targets CLASSES=`find . -name "*.class"` for i in $CLASSES ; do \ mingw32-gcj -c -o `echo $i | sed -e 's/\.class/\.o/'` $i --classpath . \ done mingw32-gcj --shared -o libpoi-hssf.dll `find org -name "*.o"` -lgcj -Wl,--out-implib,libpoi-hssf.dll.a -Wl,--enable-runtime-pseudo-reloc
cd .../swt-windows-src
mingw32-gcj -c --resource=org/eclipse/swt/internal/SWTMessages.properties -o SWTMessages.o org/eclipse/swt/internal/SWTMessages.properties
echo <<"EOF" > SWTImageLoaders.java
package org.eclipse.swt.internal.image;
public class SWTImageLoaders
{
static
{
GIFFileFormat x = new GIFFileFormat();
PNGFileFormat y = new PNGFileFormat();
JPEGFileFormat z = new JPEGFileFormat();
WinBMPFileFormat q = new WinBMPFileFormat();
WinICOFileFormat p = new WinICOFileFormat();
}
}
EOF
mingw32-gcj -c -o SWTImageLoaders.o SWTImageLoaders.java
mingw32-gcj -fjni --shared -o libswt.dll `find . -name "*.o"` -lgcj -Wl,--out-implib,libswt.dll.a -Wl,--enable-runtime-pseudo-reloc -lswt-win32-2135 -L.
| Topic NativeHowto . { Edit | Attach | Ref-By | Printable | Diffs | r1.6 | > | r1.5 | > | r1.4 | More } |
|
Revision r1.6 - 28 Apr 2005 - 11:54 GMT - TWikiGuest Parents: WebHome |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |