This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: -shared option
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: rmathew at hotmail dot com
- Cc: java at gcc dot gnu dot org
- Date: Wed, 2 Apr 2003 12:04:37 +1000 (EST)
- Subject: Re: -shared option
"Ranjit Mathew" <rmathew at hotmail dot com> wrote
>
> ---------------------------- 8< --------------------------------
>
> I compile this to an object file:
>
> gcj -c Foo.java
>
> I now get the symbols that ought to be exported:
> ---------------------------- 8< --------------------------------
> C:\> nm Foo.o |find "T "
>
> 00000000 T __ZN3Foo3barEv
> 0000004a T __ZN3FooC1Ev
>
> C:\> nm Foo.o |find "D "
>
> 00000080 D __ZN3Foo6class$E
> 00000040 D __ZTVN3FooE
> ---------------------------- 8< --------------------------------
> (getting the defined "text" and "data" symbols)
>
> ...and create a DEF file "foo.def" with these symbols:
You need to mark DATA
> ---------------------------- 8< --------------------------------
> EXPORTS
> _ZN3Foo3barEv
> _ZN3FooC1Ev
_ZN3Foo6class$E DATA
_ZTVN3FooE DATA
> ---------------------------- 8< --------------------------------
The other way:
dlltool --output-def foo.def --export-all foo.o
and then comment out what you don't want to export.
> (Note that the leading underscores have been stripped.)
>
> I now create the DLL using the command:
>
> gcj -shared -o foo.dll Foo.java foo.def
>
> Linking against this DLL is simple:
>
> gcj --main=HelloWorld HelloWorld.java foo.dll
>
> ...though the created executable directly throws a
> NullPointerException. :-(
You can only access DATA like this
*_imp__ZTVN3FooE
so you either
(1) need the dllimport for imported objects in client code
(2) use --enable auto-import and (probabaly) --enable-runtime-pseudo-reloc to
fixup
Note there are fish-hooks in C++ with dllimport and virtual methods and
artificial variables (eg, typeinfo objects) generated by the compiler. I expect
the same in Java.
Danny
>
> I'll have to investigate this a bit more...
>
> Ranjit.
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.