This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: win32: Why exports of JNI_* symbols from _exe_ files
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: Jeff Sturm <jsturm at one-point dot com>
- Cc: java at gcc dot gnu dot org
- Date: Tue, 5 Aug 2003 12:10:19 +1000 (EST)
- Subject: Re: win32: Why exports of JNI_* symbols from _exe_ files
--- Jeff Sturm <jsturm@one-point.com> wrote: > On Tue, 5 Aug 2003, [iso-8859-1] Danny Smith
wrote:
> > Is there a reason for these symbols always to be exported from
> > .exe file?
>
> Probably no good reason.
>
> When jni.o is built, how can it know if its final destination is a
> .exe or .dll?
>
*shrug*
> Jeff
Okay, here is the problem that motivated my question.
jni.h declares these symbols to user-land as __declspec(dllimport), so that will
create references to __imp__JNI*.
Consider this:
The libarary:
/* foo.c */
void __declspec(dllexport) foo()
{ }
The client:
/* main.c */
extern __declspec(dllimport) void foo();
int main()
{
foo();
return 0;
}
gcc -c foo.c
gcc main.c foo.o
D:\TEMP/ccWgaaaa.o(.text+0x1f):main.c: undefined reference to `_imp__foo'
Removing __declspec(dllimport) from the declaration of foo in main.c fixes.
Also, even if foo() does live in dll and has the __imp__ prefix, the
dllimport attribute is not necessary and the fixup will occur in the dll.
Likewise, removing JNIIMPEXP attributes from declarations in jni.h will allow
userland code to reference the JNI_* symbols whether they live in dll or static lib.
I'm wondering if the JNIEXP attribute should also be removed from the definitions
in jni.cc. If you want to specify what goes into a .dll, can always use a .DEF file
when building the dll (or .exe for that matter).
Danny
http://personals.yahoo.com.au - Yahoo! Personals
- New people, new possibilities! Try Yahoo! Personals, FREE for a limited period!