|
From: Michael B. <mic...@gm...> - 2005-11-30 12:34:41
|
Hi! I'm compiling LWJGL (www.lwjgl.org). Well, if the name tells you nothing, don't worry: to simplify the case it is a JNI native wrapper to opengl. I was compiling the win32 build (v0.98) of the library. It conststs of a bunch of java sources and a precompiled DLL(s). I'm not too font of make syntax so I used Ant to build it. The buils dcript is below. I used mingw 3.4.4-20050522 builds of core, java, c++, binutils 2.26.91-20050827, w32api 3.5, runtime 3.9; Everything compiled fine using the script below. As a result I got liblwjgl.a and XYZ.a for each native XYZ.DLL using dlltool and impdef. Then I tried to compile a very simple sample. Compillation and linking went fine. (however! linker did require any of the XYZ.a libraries!). But the resulting exe crashes immediately with message: exception in thread "main" . It doesn't care if the native DLLs are available for it or no. Actually, abstracting from the LWJGL library I build, am I missing something related to JNI or DLLs? Wrong flags, version etc? Actually, I know that the LWJGL lib IS compilable with GCJ for win32, so it is very unlikely that it's the problem in the library itself. I have experimented with different samples, but all crash. Just having a dependency on any part of my lwjgl.a makes it crash. Please, if someone can see the problem... Thakn you!!! Michael. P.S. posting to: min...@li... ja...@gc... build.xml: -------------------------------------------------------------- <?xml version="1.0"?> <project name="lwjgl-custom" default="all"> <property file="build.properties" /> <!--ant-contrib: foreach, propertyregex tasks --> <taskdef resource="net/sf/antcontrib/antlib.xml"> <classpath> <pathelement location="${basedir}/ant/ant-contrib.jar" /> </classpath> </taskdef> <target name="clean"> <delete dir="${dir.obj}" /> <delete dir="${dir.lib}" /> </target> <target name="compile"> <mkdir dir="${dir.obj}" /> <foreach target="compile-single" param="f"> <fileset dir="${dir.src}"> <include name="**/*.java" /> </fileset> </foreach> </target> <target name="compile-single"> <echo>compiling ${f} </echo> <propertyregex input="${f}" regexp="(.)*${dir.src}(\\|\/)?" property="t1" replace="" /> <propertyregex input="${t1}" regexp="\.java" property="t2" replace="" /> <propertyregex input="${t2}" regexp="(\\|\/)" property="obj" replace="_" /> <exec executable="gcj"> <env key="PATH" value="${path.gcc.bin}" /> <arg line="-fjni -g0" /> <arg line="-c ${f} " /> <arg line="-o ${basedir}/${dir.obj}/${obj}.o" /> <arg line="--classpath=${basedir}/${dir.src}" /> </exec> </target> <target name="lib"> <echo>creating library...</echo> <mkdir dir="${dir.lib}/" /> <exec executable="ar" dir="${basedir}/${dir.obj}"> <env key="PATH" value="${path.gcc.bin}" /> <arg line="ar -rcs ${basedir}/${dir.lib}/liblwjgl.a *.o" /> </exec> <exec executable="ranlib"> <env key="PATH" value="${path.gcc.bin}" /> <arg line="${basedir}/${dir.lib}/liblwjgl.a" /> </exec> </target> <target name="lib-native"> <echo>generating lib-files from native libraries...</echo> <foreach target="def-single" param="f"> <fileset dir="${dir.native}"> <include name="*.dll" /> </fileset> </foreach> </target> <target name="def-single"> <echo>creating def file for ${f} </echo> <propertyregex input="${f}" regexp="(.)*${dir.native}(\\|\/)?" property="t1" replace="" /> <propertyregex input="${t1}" regexp="\.dll\Z" property="def" replace=".def" /> <propertyregex input="${t1}" regexp="\.dll\Z" property="lib" replace=".a" /> <exec executable="impdef" output="${dir.lib}/${def}"> <env key="PATH" value="${path.impdef}" /> <arg line="${f}" /> </exec> <exec executable="dlltool" > <env key="PATH" value="${path.gcc.bin}" /> <arg line="-d ${dir.lib}/${def}" /> <arg line="-D ${f}" /> <arg line="-l ${dir.lib}/${lib}" /> <arg line="-k -A" /> </exec> </target> <target name="all"> <antcall target="clean" /> <antcall target="compile" /> <antcall target="lib" /> </target> </project> build.properties ------------------------------------------------------------ path.gcc.bin=C:\\home\\wingw\\bin path.impdef=C:\\home\\wingw\\bin dir.src=src dir.obj=obj dir.lib=lib dir.native=native make.cmd ------------------------------------------------------------ gcj -fjni -c Test.java -otest.o --classpath=lwjgl.jar gcj -fjni -o test.exe test.o --main=Test -L. -llwjgl -l-org-w3c-dom |